Dear stackoverflow experts,
I have two tables
table1<-read.table("table1.txt",header=TRUE)
table2<-read.table("table2.txt",header=TRUE)
I want to select from table 1 all of the values that match values of the first column of table 2. I have try sqldf, but I´m not sure of the syntax,
selection<-sqldf("SELECT *, column1 from table1 WHERE column1 like column2 from table2")
Any suggestion?
You can try the following:
What happens here is that the
sapplystatement is returning a logical list indicating which elements oftable1are intable2‘s first column. We are then using that logical vector to indextable1