[R] R column assignment fails for lists
Yasir Suhail
yasir.suhail at gmail.com
Wed May 4 01:13:31 CEST 2016
Dear R developers and users,
Consider the object :
> a <- data.frame(a=c(1,2), b=c(2,3), c=c("a,b","c,d"), stringsAsFactors = F)
> a$c <- strsplit(a$c, ",")
Re-assignment works fine for columns 1 and 2, but fails for column 3. If a
is a valid object, the assignment should work.
> a[,1] <- a[,1]
> a[,2] <- a[,2]
> a[,3] <- a[,3]
Warning message:
In `[<-.data.frame`(`*tmp*`, , 3, value = list(c("a", "b"), c("c", :
provided 2 variables to replace 1 variables
[[alternative HTML version deleted]]
More information about the R-help
mailing list