df$x is list so you have to use this type of assignment
> df$x[[1]] <- c('a','b')
> df
yx
1 1 a, b
2 1 f, c
3 1a
> df$x[[3]] <- letters
> df
yx
1 1 a, b
2 1 f, c
3 1 a, b, c,
> str(df)
'data.frame': 3 obs. of 2 variables:
$ y: num 1 1 1
$ x:List of
Hi All,
I need to place lists or vectors within dataframes as single
elements. However when I try this:
df=data.frame(y=1, x=I(list(c("a","b"), c("f","c"), c("a"
df
df[1,'x']=I(c("a","d"))
I get this error, even though I am using I():
Error in `[<-.data.frame`(`*tmp*`, 1, "x", value = c
2 matches
Mail list logo