There are almost surely a brazillion ways. Here's one:
Call your data frame "X". Do:
XT <- xtabs(AvailableMW~Bands+FuelTypeNum,data=X)
PXT <- 100*XT/apply(XT,1,sum)
print(round(PXT,2))
This gives percent of fuel type 1 in band PB0 as
0.54 53.87 3.93 41.65
to two decimal places
On Jun 8, 2012, at 6:15 PM, jcrosbie wrote:
How would I find the Percent of FuelTypeNum within the Band given
AvailableMW?
example:
type 1 is 1% of PB0
type 2 is 54% of PB0
type 4 is 4% of PB0
type 5 is 42% of PB0
format( 100*prop.table(table(dfrm$FuelTypeNum)), 0 )
... should do
How would I find the Percent of FuelTypeNum within the Band given
AvailableMW?
example:
type 1 is 1% of PB0
type 2 is 54% of PB0
type 4 is 4% of PB0
type 5 is 42% of PB0
Note: the Bands and fuel types are not always constant.
Data:
FuelTypeNum Bands AvailableMW Avai
3 matches
Mail list logo