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

qed picture qed · May 3, 2013 · Viewed 69.4k times · Source

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

Answer

qed picture qed · May 3, 2013

Simple, just do this:

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