I have this data:
data <- structure(list(client_id = c("A", "B",
"C", "D", "E", "F"
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
Where I need to match it with this data_to_match
:
data_to_match <- structure(list(client_id = c("A", "E", "F"
)), row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame"
))
Such as:
data[data$client_id %in% data_to_match,] # returns empty
I have tried without success (which are the solutions to various questions here):
as.list(data_to_match)
list(data_to_match)
unlist(as.list(data_to_match))
But If I create a list from scratch it works perfectly:
data_to_match_created_as_list <- c("A", "E", "F")
data[data$client_id %in% data_to_match_created_as_list,] # it returns the right rows
At the end, my question is, how do I transform the data_to_match
to a list like data_to_match_created_as_list
?
In addition, how is the right name for this different types of list? I looked up for how to transform vector or one-column dataframe to list and the solutions are not equal to a list created from scratch (as in the example above and my multiple tries)