I have a single list of numeric vector and I want to combine them into one vector. But I am unable to do that. This list can have one element common across the list element. Fin
Doing it the tidyverse way:
library(tidyverse)
lst %>% reduce(c) %>% unique
This uses the (uncapitalized) reduce
version from purrr in combination with pipes. Also note that if the list contains named vectors, the final naming will be different depending on whether unlist
or reduce
methods are used.