2

Such a simple question that I am probably just failing at googling an easy answer.

I have a list of named character vectors. I would like to turn each element in the list into a character vector by the name of the list item. Toy example:

    #// input
    groups <- list(letters = c("a", "b", "c"),
                names = c("peter", "paul"))
    groups
    #> $letters
    #> [1] "a" "b" "c"
    #> 
    #> $names
    #> [1] "peter" "paul"

    #// stuff I don't want to do manually
    letters <- groups[[1]]
    names <- groups[[2]]

    #// desired output
    letters
    #> [1] "a" "b" "c"
    names
    #> [1] "peter" "paul"

Created on 2021-01-28 by the reprex package (v0.3.0)

Mario Niepel
  • 1,095
  • 4
  • 19

0 Answers0