[R] Obtain a list of data tables from a main data table

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Oct 8 18:00:55 CEST 2014


Please be aware that by posting your question in HTML format instead of plain text you have sent us a corrupted message. Please adjust your email software settings when sending to this list.

I thought the whole purpose of data.table was to allow group data processing without creating oodles of separate tables.

What is your intended use of ask if these tables?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On October 8, 2014 9:06:30 AM MDT, "Frank S." <f_j_rod at hotmail.com> wrote:
> 
>
>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 at 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.



More information about the R-help mailing list