[R] The contrary of command %in%
Dear r-list, I've got a data base: HData[1:10,] NumTree Site Species Date Age DBHH IdentTree 11 Queige Spruce 2002 184 49 33.5 Queige 1 22 Queige Fir 2002 NA 5 4.6 Queige 2 33 Queige Fir 2002 25 8 6.6 Queige 3 44 Queige Spruce 2002 198 47 32.5 Queige 4 55 Queige Fir 2002 200 59 35.3 Queige 5 66 Queige Spruce 2002 80 16 9.4 Queige 6 77 Queige Fir 2002 NA 5 4.2 Queige 7 88 Queige Fir 2002 200 44 32.5 Queige 8 99 Queige Fir 2002 NA 5 3.4 Queige 9 10 10 Queige Spruce 2002 167 48 32.8 Queige 10 ... I want to remove particular points determined by HDataPartP-HData[H1.30,] and HDataPartP2-HData[H8DBH20,] That's why I want to use subset in a close form to: HData2-subset(HData,HData$H1.30HData$IdentTree not%in%HDataPartP2$IdentTree) How should I do that ? Is there any R-syntax saying not element of that object ? Thanks for your help. Ghislain. -- Ghislain Vieilledent 06 24 62 65 07 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The contrary of command %in%
a - 1:10 a [1] 1 2 3 4 5 6 7 8 9 10 c(1,2,3,11,12,13) %in% a [1] TRUE TRUE TRUE FALSE FALSE FALSE ! c(1,2,3,11,12,13) %in% a [1] FALSE FALSE FALSE TRUE TRUE TRUE Is this it? Gabor On Thu, Apr 20, 2006 at 02:54:39PM +0200, Ghislain Vieilledent wrote: Dear r-list, I've got a data base: HData[1:10,] NumTree Site Species Date Age DBHH IdentTree 11 Queige Spruce 2002 184 49 33.5 Queige 1 22 Queige Fir 2002 NA 5 4.6 Queige 2 33 Queige Fir 2002 25 8 6.6 Queige 3 44 Queige Spruce 2002 198 47 32.5 Queige 4 55 Queige Fir 2002 200 59 35.3 Queige 5 66 Queige Spruce 2002 80 16 9.4 Queige 6 77 Queige Fir 2002 NA 5 4.2 Queige 7 88 Queige Fir 2002 200 44 32.5 Queige 8 99 Queige Fir 2002 NA 5 3.4 Queige 9 10 10 Queige Spruce 2002 167 48 32.8 Queige 10 ... I want to remove particular points determined by HDataPartP-HData[H1.30,] and HDataPartP2-HData[H8DBH20,] That's why I want to use subset in a close form to: HData2-subset(HData,HData$H1.30HData$IdentTree not%in%HDataPartP2$IdentTree) How should I do that ? Is there any R-syntax saying not element of that object ? Thanks for your help. Ghislain. -- Ghislain Vieilledent 06 24 62 65 07 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The contrary of command %in%
Just negate the result of %in%; e.g., ! a %in% b Andy From: Ghislain Vieilledent Dear r-list, I've got a data base: HData[1:10,] NumTree Site Species Date Age DBHH IdentTree 11 Queige Spruce 2002 184 49 33.5 Queige 1 22 Queige Fir 2002 NA 5 4.6 Queige 2 33 Queige Fir 2002 25 8 6.6 Queige 3 44 Queige Spruce 2002 198 47 32.5 Queige 4 55 Queige Fir 2002 200 59 35.3 Queige 5 66 Queige Spruce 2002 80 16 9.4 Queige 6 77 Queige Fir 2002 NA 5 4.2 Queige 7 88 Queige Fir 2002 200 44 32.5 Queige 8 99 Queige Fir 2002 NA 5 3.4 Queige 9 10 10 Queige Spruce 2002 167 48 32.8 Queige 10 ... I want to remove particular points determined by HDataPartP-HData[H1.30,] and HDataPartP2-HData[H8DBH20,] That's why I want to use subset in a close form to: HData2-subset(HData,HData$H1.30HData$IdentTree not%in%HDataPartP2$IdentTree) How should I do that ? Is there any R-syntax saying not element of that object ? Thanks for your help. Ghislain. -- Ghislain Vieilledent 06 24 62 65 07 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] The contrary of command %in%
A flexible way for doing this is to define logical vectors for the types of samples that you want to include or exclude. You can then use logical negation to select the complementary set: inSet1 - HData$H 1.3 inSet2 - HData$H 8 Hdata$DBH 20 HDataPart1 - Hdata[!inSet1, ] HDataPart2 - Hdata[!inSet2, ] -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ghislain Vieilledent Sent: Thursday, April 20, 2006 8:55 AM To: r-help@stat.math.ethz.ch Subject: [R] The contrary of command %in% Dear r-list, I've got a data base: HData[1:10,] NumTree Site Species Date Age DBHH IdentTree 11 Queige Spruce 2002 184 49 33.5 Queige 1 22 Queige Fir 2002 NA 5 4.6 Queige 2 33 Queige Fir 2002 25 8 6.6 Queige 3 44 Queige Spruce 2002 198 47 32.5 Queige 4 55 Queige Fir 2002 200 59 35.3 Queige 5 66 Queige Spruce 2002 80 16 9.4 Queige 6 77 Queige Fir 2002 NA 5 4.2 Queige 7 88 Queige Fir 2002 200 44 32.5 Queige 8 99 Queige Fir 2002 NA 5 3.4 Queige 9 10 10 Queige Spruce 2002 167 48 32.8 Queige 10 ... I want to remove particular points determined by HDataPartP-HData[H1.30,] and HDataPartP2-HData[H8DBH20,] That's why I want to use subset in a close form to: HData2-subset(HData,HData$H1.30HData$IdentTree not%in%HDataPartP2$IdentTree) How should I do that ? Is there any R-syntax saying not element of that object ? Thanks for your help. Ghislain. -- Ghislain Vieilledent 06 24 62 65 07 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html