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

r, r-faq

Solution

Simple, just do this:

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

Problem

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 ```

Original source