Lots of ways to do this, I use %in% with bracket notation [row, column]. The empty column argument below returns all columns but you could have conditional logic there as well.
dd[dd$rows %in% test_rows, ] On Mon, Jun 8, 2015 at 6:44 PM, Bogdan Tanasa <tan...@gmail.com> wrote: > Dear all, > > would appreciate your suggestions on subsetting a dataframe : please let's > consider an example dataframe df: > > dd<-c(1,2,3) > rows<-c("A1","A2","A3") > columns<-c("B1","B2","B3") > numbers <- c(400, 500, 600) > df <- dataframe(dd,rows,columns, numbers) > > and a vector : test_rows <-c("A1","A3") ; > > how could I subset the dataframe df function of vector test_rows, in such a > way that only the lines of dataframe df (df$rows) that match the elements > of test_rows ("A1" and "A3") are listed ? > > thank you very much, > > -- bogdan > > [[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. > [[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.