I have a list that looks like this:
$fec9
[1] "yes"
$`39c1`
[1] "no"
$d387
[1] "yes"
$`0065`
[1] "yes"
and a dataframe that has matching keys to the list's elements as such:
dataframe <- data.frame(key = c('39c1', 'fec9', 'p731' '0065', 'd387'),
label = c('trash', 'wash car', 'cook dinner', 'mow lawn', 'vacuum'))
I am trying to rename each element in the list the corresponding key's label but the data frame is not in the same order as the list and there are some keys in the dataframe that do not appear in the list. currently I am trying:
for(i in names(list)){
names(list[i]) <- dataframe %>% filter(key == names(list[i])) %>% select(label)
}
However when I inspect the list after the names have all remained the same