I have a dataframe like:
df<-data.frame(x=1:5,y=6:10,z=11:15)
x y z
1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
Now I would like to create a list new_list where every element is a single column of as a vector.
This would look like:
str(new_list)
list of 3
$ : num[1:5] 1 2 3 4 5
$ : num[1:5] 6 7 8 9 10
$ : num[1:5] 11 12 13 14 15
I tried:
new_list <-lapply(df,c)
but this only returend
list of 3
$ : num[1:5] 1
$ : num[1:5] 6
$ : num[1:5] 11
Note: I hope my goal is clear. If not plese let me know.