1

i try to work with the ff package. In this context i try to cbind two ff dataframes. I found a solution to combine a ffdf with a ff vector but how do i combine to ffdf. Here my code for combining ffdf with ff vector:

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

Thanks a lot for your help

yemmit
  • 13
  • 2
  • Why not simply do dis$yourcolumnname <- bf$yourcolumnname? –  Aug 21 '13 at 11:06
  • Or do dis$yourcolumnname <- clone(bf$yourcolumnname) - this one will make a copy of the ff file so that you can work on it in the dis ffdf without affecting the bd ffdf. –  Aug 21 '13 at 11:26
  • Well thanks for your answer. Well i managed to solve my problem with merge(), too. But your solution works too so thanks anyway. – yemmit Aug 21 '13 at 11:37
  • @yemmit If you solved your problem, please write it up as an answer to your question, so others can benefit from seeing the solution. Otherwise, this is just a stub of a question that won't benefit anyone later. – Dinre Aug 21 '13 at 12:10
  • 1
    Possible duplicate of [How to column bind two ffdf](http://stackoverflow.com/questions/20602751/how-to-column-bind-two-ffdf) – jbaums Nov 16 '15 at 22:21

1 Answers1

1

Question has been answered here: How to column bind two 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)[,]
Community
  • 1
  • 1
Audrey
  • 212
  • 4
  • 15