[R] to delete lines by means of a vector

2013-09-10 Thread Arnaud Michel
Hi I would like to eliminate a large number of lines of the dataframe df1 The lines to delete are given here by the values of Mat (ex : 2,4,7,10). but I have a large number (300) values of Mat dput(df1) structure(list(Mat = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5

Re: [R] to delete lines by means of a vector

2013-09-10 Thread Rui Barradas
Hello, It seems you've made a mistake and posted df1 twice, identical(df1, df2) # TRUE As for your question, try negating ?%in% MatDelete <- c(2, 4, 7, 10) df3 <- df1[!df1$Mat %in% MatDelete, ] Hope this helps, Rui Barradas Em 10-09-2013 16:03, Arnaud Michel escreveu: Hi I would like

Re: [R] to delete lines by means of a vector

2013-09-10 Thread Bert Gunter
?match ## or ?"%in%" ## if vec is the vector of values you want to omit, something like df2 <- df1[! (df1$Mat %in% vec),] ## the parentheses may be unnecessary Cheers, Bert On Tue, Sep 10, 2013 at 8:03 AM, Arnaud Michel wrote: > Hi > I would like to eliminate a large number of lines of the

Re: [R] to delete lines by means of a vector

2013-09-10 Thread arun
Hi, Try: vec1<- c(2,4,7,10) df1New<-df1[!df1$Mat %in% vec1,]  dim(df1New) #[1] 43  3 A.K. - Original Message - From: Arnaud Michel To: R help Cc: Sent: Tuesday, September 10, 2013 11:03 AM Subject: [R] to delete lines by means of a vector Hi I would like to eliminate a large