Hi everybody,
I have (as an example) the following two data tables: all <- data.table(ID = c(rep(c(100:105),c(3,2,2,3,3,3))), value = c(100,120,110,90,45,35,270,50,65,40,25,55,75,30,95,70)) DT <- data.table(ID = 100:105, code=c(2,1,3,2,3,1)) My aim is to construct as many sub data tables as different values for the integer variable code, and I have done: code_1 <- all[ID %in% DT[code==1]$ID] code_2 <- all[ID %in% DT[code==2]$ID] code_3 <- all[ID %in% DT[code==3]$ID] Because maximum code value can be very high, �is it possible to obtain a list of the above 3 data tables through a loop? I mean something like: for (i in 1:max(DT$code)){ paste(code,�_�,[i]) <- } return(list)] Thank you very much to all the members! [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.