store something as a list in a data fram r code example
Example: store list in data.frame R
# Add a list to data.frame in single 'element' slot
# 1) Make data.frame from named list (names are optional)
rowA <- as.list(c(1,2,3,4,5))
names(rowA) <- c("A", "B", "C", "D", "E")
data.df <- data.frame(rowA, stringsAsFactors=FALSE)
data.df
# A B C D E
# 1 1 2 3 4 5
#
# 2) Make lists you want to add to data frame:
numeric.X <- as.numeric(c(100,200,300,400))
# 3) Add List as new column to data.frame:
data.df$X <- list(numeric.X)
data.df
# A B C D E X
# 1 1 2 3 4 5 100, 200, 300, 400