haotu : an open lab notebook

2015/01/30

aggregate more than one column in data.table

Filed under: R — Tags: , , , , — S @ 11:15
# Average ability by grade
agg1<- fm1[, j=list(mean(x0, na.rm = TRUE),mean(x1, na.rm = TRUE)),by = key]

http://rprogramming.net/aggregate-data-in-r-using-data-table/

Advertisements

2015/01/22

add column in data.table

Filed under: Manipulate Data in R, R, R, R Stats — S @ 07:09
DT[,new1:=v$r1]

 

Here is a post to add multiple columns to a data.table

http://stackoverflow.com/questions/11308754/add-multiple-columns-to-r-data-table-in-one-function-call

Blog at WordPress.com.