1

我尝试使用 ff 包。在这种情况下,我尝试 cbind 两个 ff 数据帧。我找到了一个将 ffdf 与 ff 矢量结合的解决方案,但我如何结合到 ffdf。这是我将 ffdf 与 ff 矢量结合的代码:

library(ff)
## read Bankfull flow##
setwd(wd)
bf <- read.csv.ffdf(file="G_BANKFULL_km3month.csv",header=TRUE)
## read river discharge global, monthly vlaues 1971-2000##
memory.limit(size=16000)   # increase working memory
dis <- read.table.ffdf(file='RIVER_AVAIL_7100_WG22.txt', header=T, sep="\t", dec=".")
##read bankfull values as ff object##
bfvalues <- ff(bf[,2])
##combination of bf and dis ( see test <- cbind(dis,bf$VALUE))
dis_bf <- do.call('ffdf', c(physical(dis), list(bfvalues=bfvalues)))

非常感谢你的帮助

4

1 回答 1

1

问题已在此处得到解答:如何列绑定两个 ffdf

library(ff)
ff1 <- as.ffdf(data.frame(letA = letters[1:5], numA = 1:5))
ff2 <- as.ffdf(data.frame(letB = letters[6:10], numB = 6:10))

cbind.ffdf2 <- function(d1, d2){
D1names <- colnames(d1)
D2names <- colnames(d2)
mergeCall <- do.call("ffdf", c(physical(d1), physical(d2)))
colnames(mergeCall) <- c(D1names, D2names)
mergeCall
}

cbind.ffdf2(ff1, ff2)[,]
于 2014-03-07T11:18:55.113 回答