Convert a R vector into a list, each element in the vector as an element in the list

Tag: r Author: Cyn_ki Date: 2013-04-17

The vector is like this:

c(1,2,3)
#[1] 1 2 3

I need something like this:

list(1,2,3)
#[[1]]
#[1] 1
#
#[[2]]
#[1] 2
#
#[[3]]
#[1] 3

I tried this:

list(c(1,2,3))
#[[1]]
#[1] 1 2 3
oh my, I just found out: as.list(c(1,2,3))
Then I think you can just delete your question!
... or better yet, supply your findings as an answer so that others can quickly find it in the future
Maybe someone will find it helpful? :)

Other Answer1

Simple, just do this:

as.list(c(1,2,3))