[R] Reshape

Kimberly Harris-McCoy kmcreed32 at hotmail.com
Thu Oct 17 04:18:38 CEST 2013


Hello,
 
I have data frame like the one created below,
 

 ##input data
Person <- c(1,1,1,1,1,1,2,2)
Amount <- c(100,10,100,10,100,10,50,150)
Date <- c("12/01/2012", "12/01/2012", "01/01/2013","01/01/2013","02/01/2013","02/01/2013","12/01/2012","12/01/2012")
df <- data.frame(Person,Amount,Date)
 
I would like to transpose the Amount data so that I can get the total amount paid by person and date.
So, it would look something like:
 
 
##Want it to look like:
 
Person Date              Amt1      Amt2
1          12/01/2012    100       10
1           01/01/2013   100       10
1           02/01/2013   100       10
2          12/01/2012     50        150
 
 
I have been working with reshape, but I am having trouble getting it to look exactly right.
Thank you,
K 		 	   		  


More information about the R-help mailing list