If I understand correctly what you need, you can express it using dplyr:
> data %.% group_by( zipcode, Type ) %.% summarise( power = sum(power) )
Source: local data frame [5 x 3]
Groups: zipcode
zipcode Type power
1 21459 windpower 6
2 79280 windpower 2
3 79280 biogas 55
4 79283 hydroelectric 3
5 79280 solarpower 6
And if you only want those zip code that start by 2
, you can filter
first:
> data %.% filter( grepl( "^2", zipcode ) ) %.%
group_by( zipcode, Type ) %.% summarise( power = sum(power) )
Source: local data frame [1 x 3]
Groups: zipcode
zipcode Type power
1 21459 windpower 6