Suppose I have the following dataset
d <- data.frame(1:31, 31:1)
names(d) <- c("1st", "2nd")
And I want to select the columns where "3" occurs in the column named "1st" (i.e. column 3, 13 and 31 should be selected, but not column 1, 9, and 29).
sqldf("select * from d where 1st LIKE '%3%'")
gives me the error:
Error: unrecognized token: "1st"
How can I selectively subset part of a data frame based on a partial match?
Desired output:
1st 2nd
3 29
13 19
31 1
Any help is much appreciated