I have the following data structure in R:
df <- structure(
list(
ID = c(1L, 2L, 3L, 4L, 5L),
var1 = c(\'a\', \'b\', \'c\', \'d\', \'e\'),
var2 =
I think the strucutre makes it pretty clear
str(df)
# 'data.frame': 5 obs. of 4 variables:
# $ ID : int 1 2 3 4 5
# $ var1: chr "a" "b" "c" "d" ...
# $ var2:'data.frame': 5 obs. of 2 variables:
# ..$ var2a: chr "v" "w" "x" "y" ...
# ..$ var2b: chr "vv" "ww" "xx" "yy" ...
# $ var3: chr "aa" "bb" "cc" "dd" ...
It's a data.frame with a column (var2
) that contains a data.frame. This isn't super easy to create so i'm not quite sure how you did it but it isn't technically "illegal" in R.
data.frames can contain matrices and other data.frames. So it doesn't just look at the length()
of the elements, it looks at the dim()
of the elements to see if it has the right number of "rows".
I often "fix" or expand these data.frames using
fixed <- do.call("data.frame", df)