简体   繁体   中英

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?

This should work:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM