rdataframebigdataffffbase

Adding a column with character data to a ffdf


I've tried to add a Source column to my ffdf, but can't seem to get it to work... if it was a normal df I would simply write

mtcars$NewCol <- "AB" 

If I do this for the ffdf it returns an error

require(ff)
require(ffbase)

mtcarsff <- as.ffdf(mtcars) 
mtcars$NewCol <- "testname"

Error in `[[<-.ffdf`(`*tmp*`, i, value = "testname") : 
assigned value must be ff

Any Ideas?


Solution

  • This should work:

    mtcarsff$NewCol <- as.ff(
        rep(factor("AB"), times = nrow(mtcarsff))
    )
    

    Note that "AB" must be considered a factor, not a character.