a <- data.frame(x=c(1,2,3), y=c(10,10,20))
a
x y
1 1 10
2 2 10
3 3 20
a$z = a$x / a$y # works with data frame
a
x y z
1 1 10 0.10
2 2 10 0.20
3 3 20 0.15
a <- data.frame(x=c(1,2,3), y=c(10,10,20))
a_ff <- as.ffdf(a)
a_ff$z = a_ff$x / a_ff$y # throws an error for a ff data frame
Error in a_ff$x/a_ff$y : non-numeric argument to binary operator
How do I update a ff data frame to add a column?
I have checked both ff and ffbase packages documentation but cannot find an example on how to do that.
I managed to get the operations done with: z <- ffdfwith(a_ff, x/y)
but then I do not know how to update the ff data frame with the new vector.
I am able to reproduce the error. I guess you need ffbase
a_ff$z = a_ff$x / a_ff$y #
#Error in a_ff$x/a_ff$y : non-numeric argument to binary operator
library(ffbase)
a_ff$z = a_ff$x / a_ff$y
a_ff$z
# ff (open) double length=3 (3)
# [1] [2] [3]
# 0.10 0.20 0.15