I trying to get a list of string values by using group_by() clause in R. Please find a sample data below. Here is what I tried.
result <- data %>%
  group_by(station) %>%
  summarise(values = list(variable))
measurement_vars <- c("PRCP", "SNOW", "SNWD", "TMAX", "TMIN")
In this case, the values column will be a list. I want to check if the values column includes specific strings, such as measurement_vars, by using %in% function. The %in% function does not check all values in the list. Therefore, I tried to unlist() the values; however, it did not work. My question is similar to this one, but it is in SQL. Here is what I expected in the results (values will not be a list).
I want to filter the stations which include all the measurement_vars.
data <- structure(list(station = c("ACW00011604", "ACW00011604", "ACW00011604", 
"ACW00011604", "ACW00011604", "ACW00011604", "ACW00011604", "ACW00011604", 
"ACW00011604", "ACW00011604", "ACW00011604", "ACW00011647", "ACW00011647", 
"ACW00011647", "ACW00011647", "ACW00011647", "ACW00011647", "ACW00011647", 
"AE000041196", "AE000041196", "AE000041196", "AE000041196", "AEM00041194", 
"AEM00041194", "AEM00041194", "AEM00041194", "AEM00041217", "AEM00041217", 
"AEM00041217", "AEM00041217"), lat = c(17.1167, 17.1167, 17.1167, 
17.1167, 17.1167, 17.1167, 17.1167, 17.1167, 17.1167, 17.1167, 
17.1167, 17.1333, 17.1333, 17.1333, 17.1333, 17.1333, 17.1333, 
17.1333, 25.333, 25.333, 25.333, 25.333, 25.255, 25.255, 25.255, 
25.255, 24.433, 24.433, 24.433, 24.433), lon = c(-61.7833, -61.7833, 
-61.7833, -61.7833, -61.7833, -61.7833, -61.7833, -61.7833, -61.7833, 
-61.7833, -61.7833, -61.7833, -61.7833, -61.7833, -61.7833, -61.7833, 
-61.7833, -61.7833, 55.517, 55.517, 55.517, 55.517, 55.364, 55.364, 
55.364, 55.364, 54.651, 54.651, 54.651, 54.651), variable = c("TMAX", 
"TMIN", "PRCP", "SNOW", "SNWD", "PGTM", "WDFG", "WSFG", "WT03", 
"WT08", "WT16", "TMAX", "TMIN", "PRCP", "SNOW", "SNWD", "WT03", 
"WT16", "TMAX", "TMIN", "PRCP", "TAVG", "TMAX", "TMIN", "PRCP", 
"TAVG", "TMAX", "TMIN", "PRCP", "TAVG"), start = c(1949, 1949, 
1949, 1949, 1949, 1949, 1949, 1949, 1949, 1949, 1949, 1961, 1961, 
1957, 1957, 1957, 1961, 1961, 1944, 1944, 1944, 1944, 1983, 1983, 
1983, 1983, 1983, 1983, 1984, 1983), end = c(1949, 1949, 1949, 
1949, 1949, 1949, 1949, 1949, 1949, 1949, 1949, 1961, 1961, 1970, 
1970, 1970, 1961, 1966, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 
2022, 2022, 2022, 2020, 2022)), row.names = c(NA, -30L), class = c("tbl_df", 
"tbl", "data.frame"))

 
    