Hello together, i have a data.frame, which i want to filter with numbers in a vector. I have a vector (Top10) with these numbers: [1] 205 302 156 378 235 328 183 375 296 374 and i have a data.frame with a Column (CU_NO) with all my Customer numbers. How can i filter this data.frame, with the Numbers in my vector. this one doens't work: data_export_final<-data_export[(data_export$KD_NR==Top10),] Thank you. Mat -- View this message in context: http://r.789695.n4.nabble.com/filter-data-frame-with-a-vector-tp4651098.html Sent from the R help mailing list archive at Nabble.com.
When you ask the list, you should provide a reproducible example; the best being using dput(). If I understand you right, the %in% operator might be what you're looking for. See ?"%in%" HTH, Ivan -- Ivan CALANDRA Universit? de Bourgogne UMR CNRS/uB 6282 Biog?osciences 6 Boulevard Gabriel 21000 Dijon, FRANCE +33(0)3.80.39.63.06 ivan.calandra at u-bourgogne.fr http://biogeosciences.u-bourgogne.fr/calandra Le 28/11/12 10:12, Mat a ?crit :> Hello together, > > i have a data.frame, which i want to filter with numbers in a vector. > I have a vector (Top10) with these numbers: > [1] 205 302 156 378 235 328 183 375 296 374 > and i have a data.frame with a Column (CU_NO) with all my Customer numbers. > > How can i filter this data.frame, with the Numbers in my vector. > > this one doens't work: > data_export_final<-data_export[(data_export$KD_NR==Top10),] > > Thank you. > > Mat > > > > -- > View this message in context: http://r.789695.n4.nabble.com/filter-data-frame-with-a-vector-tp4651098.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Hello, ?is.element Regards, Pascal Le 28/11/2012 18:12, Mat a ?crit :> Hello together, > > i have a data.frame, which i want to filter with numbers in a vector. > I have a vector (Top10) with these numbers: > [1] 205 302 156 378 235 328 183 375 296 374 > and i have a data.frame with a Column (CU_NO) with all my Customer numbers. > > How can i filter this data.frame, with the Numbers in my vector. > > this one doens't work: > data_export_final<-data_export[(data_export$KD_NR==Top10),] > > Thank you. > > Mat > > > > -- > View this message in context: http://r.789695.n4.nabble.com/filter-data-frame-with-a-vector-tp4651098.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Hi, Try %in% vec<-c(205,302,156,378) set.seed(5) ?dat1<-data.frame(CU_NO=c(205,302,301,378,158,377,476,156),col2=runif(8,0,1)) ?dat1[dat1$CU_NO%in%vec,] #? CU_NO????? col2 #1?? 205 0.2002145 #2?? 302 0.6852186 #4?? 378 0.2843995 #8?? 156 0.8079352 A.K. ----- Original Message ----- From: Mat <matthias.weber at fnt.de> To: r-help at r-project.org Cc: Sent: Wednesday, November 28, 2012 4:12 AM Subject: [R] filter data.frame with a vector Hello together, i have a data.frame, which i want to filter with numbers in a vector. I have a vector (Top10) with these numbers: [1] 205 302 156 378 235 328 183 375 296 374 and i have a data.frame with a Column (CU_NO) with all my Customer numbers. How can i filter this data.frame, with the Numbers in my vector. this one doens't work: data_export_final<-data_export[(data_export$KD_NR==Top10),] Thank you. Mat -- View this message in context: http://r.789695.n4.nabble.com/filter-data-frame-with-a-vector-tp4651098.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
Maybe Matching Threads
- "sequence of factor settings"?
- [LLVMdev] [FastPolly]: Update of Polly's performance on LLVM test-suite
- No UID associated with this user name
- [LLVMdev] [Polly] Summary of some expensive compiler passes, especially PollyDependence
- [LLVMdev] [Polly] Summary of some expensive compiler passes, especially PollyDependence