Fish
Fish

Reputation: 131

From list of vector to list with R

I have a list of vector : [[1]]

 [1] a  

 [2] f 

 [3] e       

 [4] a 

[[2]] 

 [1] f 

 [2] f

 [3] e

I would like to know if is there a way to transform it in a list (simple list of characters) like this :

 [1] a f e a  

 [2] f f e

Thank you

Upvotes: 0

Views: 50

Answers (1)

alexwhitworth
alexwhitworth

Reputation: 4907

You can use unlist

l1 <- list(list("a", "f", "e", "a"),
           list("f", "f", "e"))

lapply(l1, unlist)
[[1]]
[1] "a" "f" "e" "a"

[[2]]
[1] "f" "f" "e"

Upvotes: 1

Related Questions