Create a data.frame where a column is a list

Slightly obscurely, from ?data.frame:

If a list or data frame or matrix is passed to ‘data.frame’ it is as
if each component or column had been passed as a separate argument
(except for matrices of class ‘”model.matrix”’ and those protected by
‘I’
).

(emphasis added).

So

data.frame(a=1:3,b=I(list(1,1:2,1:3)))

seems to work.

Leave a Comment