On 2015-01-23 11:09, Ivan Calandra wrote:
Hi Alain,

I think you're looking for %in% (see ?'%in%' for the help page)

id.vector <- c(1,3)  ## here you define the values you want to select:
x, y, z...
subset(df, id %in% id.vector)


But note the Warning in

>?subset

Göran


HTH,
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 23/01/15 10:50, D. Alain a écrit :
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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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