[R] Aggregating data by data.table

TJUN KIAT TEO teotjunk at hotmail.com
Fri Feb 19 06:34:28 CET 2016


I am trying to aggregate data using data table. Here is what I am trying to do

OrgData<-data.table(fgl)
setkey(OrgData,type)
OrgData<-OrgData[,j=list(Quant=quantile(RI),m=max(RI)),by=type]

    type  Quant     m
1:  WinF -5.850  8.67
2:  WinF -0.460  8.67
3:  WinF -0.165  8.67
4:  WinF  1.560  8.67
5:  WinF  8.670  8.67
6: WinNF -3.910 15.93
I can write a function to reshape the data in the format I want it in the columns that I want. But is there a quick way to do it directly in data.table?


 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list