-->

中的R Columnbind FF的数据帧(Columnbind ff data frames in

2019-10-18 13:12发布

我尝试用FF包工作。 在这方面,我尝试cbind 2个FF dataframes。 我发现了一个解决方案,一个ffdf与FF载体结合,但如何合并到ffdf。 在这里我为结合了FF矢量ffdf代码:

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)))

非常感谢你的帮助

Answer 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)[,]


文章来源: Columnbind ff data frames in R
标签: r bigdata ff