[R] elegant way to remove cases with many different ids

D. Alain dialvac-r at yahoo.de
Fri Jan 23 10:50:22 CET 2015


Dear R-List, 

I have nested data with cases grouped by IDs and I want to remove all cases with specific IDs. 

something like

df<-data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),var=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))

subset(df,id== 1 | id == 3)

Having a very large dataset with many IDs to remove this solution leaves me to write quite a long list of "id == x | id == y | id == z ...". I wonder if there is a more elegant way to do this? I tried with "id = c(x,y,z)" but this did not give the proper result.

Any suggestions? Thank you!

Best wishes

Alain 


 
 


	[[alternative HTML version deleted]]



More information about the R-help mailing list