DearR Users,

I have a problem which I think you might be able to help.  I have a dataframe 
which I'm trying to "filter" following different groups I specified.  It's a 
little hard to explain, so here is an example:

My dataframe:

   ESS DHP
1  EPB  22
2  SAB  10
3  SAB  20
4  BOJ  14
5  ERS  28
11 SAB  10
12 SAB  22
13 BOJ  26
20 SAB  10
21 SAB  22
22 BOJ  32
29 SAB  14
30 SAB  22
38 SAB  14
47 SAB  18

I'm trying to filter it by selecting a subgroup of ESS, for example:
 softwood<- c("EPB","SAB")

So I can obtain:
NEW dataframe:
   ESS DHP
1  EPB  22
2  SAB  10
3  SAB  20
11 SAB  10
12 SAB  22
20 SAB  10
21 SAB  22
29 SAB  14
30 SAB  22
38 SAB  14
47 SAB  18

(my real groups are actually bigger and so are my dataframe but you get the 
idea).

I have looked at subset and aggregate but it doesn't work and the loop would be 
totally inefficient. I'm sure there is a function in R that does something like 
that but I couldn't find the proper "keyword" to search for it.  

Thanks for your help,

Bastien
______________________________________________
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.

Reply via email to