I have a dataframe df with a column of text strings and a separate list of values:
c1 <- c("Jim Mackinnon","Jane Smit","Sunday 9-10","Wednesday 14-15","Friday 19-20")
c2 <- c("1123","4923","6924","4301","5023")
df <- as.data.frame(c2,c1)
df
c1 c2
Jim Mackinnon 1123
Jane Smit 4923
Sunday 9-10 6924
Wednesday 14-15 4301
Friday 19-20 5023
list_values <- c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
The aim is to select only those rows containing a value in c1 that contains one of the strings in list_values. In the example, this would mean selecting only rows 3-5 and discarding the rest. Is there a way of doing this without iteration?