I have multiple dataframes that look like this:
df.1 <- data.frame(name = c("A", "B", "C"),
                   var1 = c("cat,dog", "dog,horse,bird", "eagle,fox,chick"))
df.2 <- data.frame(name = c("A", "B", "C"),
                   var2 = c("cat,dog,worm", "dog,horse,bird", "giraffe"))
df.3 <- data.frame(name = c("A", "B", "C"),
                   var3 = c("cat,dog,worm", "dog,horse,bird,cat,lion", NA))
## merged 
all <- df.1 %>% 
  left_join(df.2) %>% 
  left_join(df.3)
> all
  name            var1           var2                    var3
1    A         cat,dog   cat,dog,worm            cat,dog,worm
2    B  dog,horse,bird dog,horse,bird dog,horse,bird,cat,lion
3    C eagle,fox,chick        giraffe                    <NA>
I would now like to merge vars1 to 3 to get a concise list without duplicates.
So for example the combined data frame should look like:
  name                    var1
1    A            cat,dog,worm
2    B dog,horse,bird,cat,lion
3    C eagle,fox,chick,giraffe
paste will allow for merging comma separated strings but I am not sure how to remove the duplicates?
I would like to do this using tidyverse and not another package.
 
     
     
     
    