[R] Subset() within function: logical error

Rich Shepard rshepard at appl-ecosys.com
Tue Jun 30 02:38:48 CEST 2015


On Tue, 30 Jun 2015, Steve Taylor wrote:

> Using return() within a for loop makes no sense: only the first one will be returned.

Steve,

   Mea culpa. Didn't catch that.

> How about:
> alldf.B = subset(alldf, stream=='B')  # etc...

   I used to do each stream manually, like the above, and want to learn how
to loop through all of them ...

> Also, have a look at unique(alldf$stream) or levels(alldf$stream) if you
> want to use a for loop on each unique value.

   ... which unique() and levels() will probably do. Will test these tomorrow
after rading the man pages.

Many thanks,

Rich



More information about the R-help mailing list