I tried to do some conversions for the same columns in data.table and found this answer . However, if I follow the steps, I get the same column names (instead of mean.Obs_1 , etc.).
library(data.table) set.seed(1) dt = data.table(ID=c(1:3), Obs_1=rnorm(9), Obs_2=rnorm(9), Obs_3=rnorm(9)) dt[, c(mean = lapply(.SD, mean), sd = lapply(.SD, sd)), by = ID] # ID Obs_1 Obs_2 Obs_3 Obs_1 Obs_2 Obs_3 #1: 1 0.4854187 -0.3238542 0.7410611 1.1108687 0.2885969 0.1067961 #2: 2 0.4171586 -0.2397030 0.2041125 0.2875411 1.8732682 0.3438338 #3: 3 -0.3601052 0.8195368 -0.4087233 0.8105370 0.3829833 1.4705692
Is there a way to avoid this behavior and get different column names for different transformations? I am using the latest (1.9.4) stable version of data.table .
r data.table
janosdivenyi
source share