Lorcan Treanor
Lorcan Treanor

Reputation: 561

rbinding two ffdf data frames in R

Another question about the ff package. Is there a rbind equivalent function in the ff or ffbase package in R? I want to bind two ff data frames by rows. Can this be done in the ff package or are there other libraries that could help me?

Upvotes: 3

Views: 3259

Answers (3)

Audrey
Audrey

Reputation: 322

rbind() works with ffdf objects as desired. For example:

df1 = as.ffdf(data.frame(A = 21:23, B = letters[1:3]))
df2 = as.ffdf(data.frame(A = 31:34, B = letters[11:14]))
df3 = as.ffdf(data.frame(A = 41:42, B = letters[21:22]))
rbind(df1, df2, df3)

Yields:

ffdf (all open) dim=c(9,2), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix PhysicalIsMatrix PhysicalElementNo PhysicalFirstCol PhysicalLastCol PhysicalIsOpen
A            A      integer       integer FALSE           FALSE            FALSE                 1                1               1           TRUE
B            B      integer       integer FALSE           FALSE            FALSE                 2                1               1           TRUE
ffdf data
   A  B
1 21 a 
2 22 b 
3 23 c 
4 31 k 
5 32 l 
6 33 m 
7 34 n 
8 41 u 
9 42 v 

Upvotes: 1

Yanchang Zhao
Yanchang Zhao

Reputation: 366

When there are no new factor levels in fd1, you can set adjustvmode to FALSE as below.

vd<-ffdfappend(fd, fd1, adjustvmode=F)

Upvotes: 1

user1600826
user1600826

Reputation:

use ffdfappend from version 0.6 of the ffbase package. The ffdfappend of version 0.5 was designed to append a data.frame to an ffdf, while the one from version 0.6 also allows appending an ffdf to an ffdf. You can install version 0.6 of that package by using the following R code:

download.file(url="http://fffunctions.googlecode.com/git-history/b6fa5617810e012e5d809d77a9a99dbb25c7e6dc/output/ffbase_0.6.tar.gz", destfile="ffbase_0.6.tar.gz")
install.packages("ffbase_0.6.tar.gz", repos=NULL)

Upvotes: 2

Related Questions