I have a dataframe df
looking like this
A B C D
1 78 12 43 12
2 23 12 42 13
3 14 42 11 99
4 49 94 27 72
I need the first two columns converted into a list which looks exactly like this:
[[1]]
[1] 78 12
[[2]]
[1] 23 12
[[3]]
[1] 14 42
[[4]]
[1] 49 94
Basically what
list(c(78, 12), c(23, 12), c(14, 42), c(49, 94)
would do. I tried this
lapply(as.list(1:dim(df)[1]), function(x) df[x[1],])
as well as
lapply(as.list(1:nrow(df)), function(x) df)
But thats slightly different. Any suggestions?