简体   繁体   English

将包含字符数据的列添加到ffdf

[英]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 我试图将Source列添加到ffdf中,但似乎无法使其正常工作...如果它是正常的df,我只会写

mtcars$NewCol <- "AB" 

If I do this for the ffdf it returns an error 如果我对ffdf执行此操作,则会返回错误

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. 请注意,必须将“ AB”视为一个因素,而不是字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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