[R] (no subject)

arun smartpink111 at yahoo.com
Thu Feb 27 08:21:14 CET 2014



Hi Dila,

Try:
transform(melt(dat,id.var=c("Day","Year")),Month=match(variable,month.abb),Amount=value)[,-c(3:4)]
A.K.




On Thursday, February 27, 2014 1:02 AM, dila radi <dilaradi21 at gmail.com> wrote:

Dear Arun,

Thank you so much for your help..but this command doesn't apply if I have more than one id. variables such as follows:

dat <- read.table(text="Day Year Jan Feb Mar Apr 
  1  2012 0 2.5 0.5 2  
  2  2013 0 6.5 0 29
  3  2013 0 9.5 0 0 
  4  2013 0 0 8 0.5 
  5  2013 0 5 0.5 110.5  
  6  2011 0 4 3.5 22  
  7  2012 11 0 12.5 3.5
  8  2011 0 5 8 36.5",sep="",header=TRUE)
library(reshape2)


I have try this but it doesnt work

res <- transform(melt(dat,id.var="Day"),Month=match(variable,month.abb),melt(dat,id.var="Year"),Amount=value)
res

Could you help me on this one..Sorry for asking again and again..
Thank you so much.

Regards,
Dila




More information about the R-help mailing list