I have a data.table like this one, but with many more columns:
library(data.table)
the_dt = data.table(DetailCol1=c("Deets1","Deets2","Deets3","Deets4"), DetailCol2 = c("MoreDeets1","MoreDeets2","MoreDeets3","MoreDeets4"), DataCol1=c("ARP","AARPP","ABC","ABC"), DataCol2=c("ABC","ABC","ABC","ARPe"), DataCol3 = c("ABC", "ARP", "ABC","ABC"))
I want to retrieve DetailCol1 of only those rows that contain a match to the string 'ARP'.
This question was useful in pointing me to like
, but I'm still not sure how do this for multiple columns, especially if there are dozens of columns in which I would like to search.
For instance, this is how I could search within DataCol1
the_dt[DataCol1 %like% 'ARP',DetailCol1]
, but how would I conduct the same search in DataCols 1-100?