[R] selection part of "subset"

Christof Kluß ckluss at email.uni-kiel.de
Mon Jan 9 18:46:24 CET 2012


Hi

thank you very much for your useful answers! In this case I solved it
with Sarah's suggestion

tab[tab[[name]] == v,]

that works fine

Greetings
Christof



Am 05-01-2012 16:51, schrieb Christof Kluß:
> Hi
> 
> I want to do something like
> 
> a <- c(10,20,15,43,76,41,25,46)
> tab <- data.frame(a)
> 
> name <- "a"
> 
> for (v in unique(tab[[name]])) {
>   r <- subset(tab, name==v)   # this does not work
>   ...
> }
> 
> i.e. a "string" on the left side of the select expression (subset). How
> could I solve this?
> 
> thx
> Christof
>



More information about the R-help mailing list