[R] Automatically naming subsets in a for loop

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri Jan 31 22:24:34 CET 2014

The standard way to do this is to use the cut function to define group categories, and then manipulate data in lists of subsets using lapply function and relatives. There are also tools such as the plyr package, data.table package, sqldf package, and the new dplyr package.

If you want more explicit help, then you really need to read the posting guide (e.g. no HTML email), and make a reproducible example (e.g. include some test data and an example calculation, even if you have to do it the long way with no loops).

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 January 31, 2014 12:11:04 PM PST, denys <denys at uoguelph.ca> wrote:
>I'm trying to subet my data based on long/lat. I have written a for
>however I am not sure how to get R to name all my subsets different
>Here is my code so far...
>for(i in 0:31){
>for(j in 0:33){
>G$i$j<-subset(G, Lat>latl & Lat<latu & Long>longl & Long<longu)
>However this just freezes my computer. 
>Any help is appreciated!
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list