I really don't know if this is a bug or can be done with some function:
Sometimes is very important to assign something to a column which name has to be access trough a variable. Normally, I have always used it with doble brackets likes this out of SparkR problems:
- df could be faithful normal data frame or data table.
- accesing by variable name:
myname = "waiting"
df[[myname]] <- c(1:nrow(df))
- or even column number
df[] <- df$eruptions
The error is not caused by the right side of the "<-" operator of assignment. The problem is that I can't assign to a column name using a variable or column number as I do in this examples out of spark. Doesn't matter if I am modifying or creating column. Same problem.
I have also tried to use this with no results:
val df2 = withColumn(df,"tmp", df$eruptions)