[R] subsetting a dataframe

Bogdan Tanasa tanasa at gmail.com
Tue Jun 9 00:44:33 CEST 2015


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]]



More information about the R-help mailing list