Skip to content
Prev 360656 / 398503 Next

R column assignment fails for lists

Try working with a 3 row dataframe. Then your misconceptions about how this proposed assignment will be more prominent because the dimensions would be wrong.

Here's an alternate approach:
[[1]]
[1] "a" "b"

[[2]]
[1] "c" "d"

[[3]]
[1] "e" "f"
[,1] [,2]
[1,] "a"  "b" 
[2,] "c"  "d" 
[3,] "e"  "f"
'data.frame':	3 obs. of  4 variables:
 $ a: num  1 2 3
 $ b: num  2 3 4
 $ 1: chr  "a" "c" "e"
 $ 2: chr  "b" "d" "f"