i have following dataset :
prod month count sub12 2012-06 566 sub1 2012-06 10239 sub6 2012-06 524 sub12 2012-07 2360 sub1 2012-07 13853 sub6 2012-07 2352 sub12 2012-08 3950 sub1 2012-08 14738 sub6 2012-08 4104
i'm trying have :
prod 2012-06 2012-07 sub12 566 2360 sub1 10239 13853 sub6 524 2352
i've run following command lines:
aperm(table(data)) data.frame(table(data))
but i'm getting wrong results.
where wrong, please?
search "reshape long wide".
data <- read.table(text="prod month count sub12 2012-06 566 sub1 2012-06 10239 sub6 2012-06 524 sub12 2012-07 2360 sub1 2012-07 13853 sub6 2012-07 2352 sub12 2012-08 3950 sub1 2012-08 14738 sub6 2012-08 4104",header=true) library(reshape2) dcast(prod~month,data=data) # prod 2012-06 2012-07 2012-08 # 1 sub1 10239 13853 14738 # 2 sub12 566 2360 3950 # 3 sub6 524 2352 4104
Comments
Post a Comment