Skip to content
Prev 201572 / 398506 Next

questions on the ff package

Jeff,
# This stores the data in an ff file, 
# but not the metadata in R's ff object. 
# To do the latter you need to do 
save(matFF, file="~/matFF.RData")

# Assuming that your ff file remains in the same location, 
# in a new R session you simply 
load(file="~/matFF.RData")
# and the ff file is available automagically
# You can create an ff object using your existing ff file by
matFF <- ff(filename="~/a.mat", vmode="double", dim=c(4,5))

# You can do the same at unknown file size with 
matFF <- ff(filename="~/a.mat", vmode="double")
# which gives you the length of the ff object
length(matFF)
# if you know the number of columns you can calculate the number of rows and give your ff object the interpretation of a matrix
dim(matFF) <- c(length(matFF)/5, 5)
# there are two ways to grow a matrix by rows

# 1) you create the matrix in major row order
matFF <- ff(1:20, dim=c(4,5), dimorder=c(2:1))
# then you require a higher number of rows
nrow(matFF) <- 6
# as you can see there are new empty rows in the file
matFF

# 2) Instead of a matrix you create a ffdf data.frame
#    which you can also give more rows using nrow<-
#    An example of this is in read.table.ffdf
#    which reads a csv file in chunks and extends the 
#    number of rows in the ffdf

Jens Oehlschl?gel