[R-sig-hpc] how to change the "ff" properties of a "ff"-related R object after the original "ff" output folder has been moved

Jens Oehlschlägel Jens.Oehlschlaegel at truecluster.com
Fri Jun 26 12:31:29 CEST 2015


I do assume that the ff-files are still at some location and not deleted 
by a finalizer. The following explains how to manipulate file locations 
with ff and ffdf objects.

Kind regards

path1 <- "c:/tmp"
path2 <- "c:/tmp2"
# create ffdf,
# using non-standard path sets finalizer to 'close' instead of 'delete'
fdf1 <- as.ffdf(iris, col_args=list(pattern=file.path(path1,"iris")))
# let's copy the old metadata (but not the files, useclone for that)
# using ffs hybrid copying semantics
fdf2 <- fdf1
# note both are open
# close the files
# and note that
# the magic has kept physical metadata in synch even in the copy
# (virtual metadata is not kept in synch
# which allows different virtual views into the same files
# not unlike SQL VIEWs virtualize dastabase TABLEs)

# filename on a ffdf
# is a shortcut for
lapply(physical(fdf2), filename)
# so filename is a physical attribute
# actually moving the files can be done with the filename<- method
lapply(physical(fdf2), function(x)filename(x) <- sub(path1, path2, 
# check this

# filename on ff
# is a shortcut for
attr(attr(fdf1$Species, "physical"), "filename")
# and if you directly manipulate this attribute
# you circummvent the filename method
# and the file itself will not be moved
attr(attr(fdf1$Species, "physical"), "filename") <- sub(path2, path1, 
# now the metadata points to a different location
# note that this physical attribute was also changed
# for the copy
# of course you can fix the erroneous metadata by
attr(attr(fdf1$Species, "physical"), "filename") <- sub(path1, path2, 
# or for all columns in a ffdf by
lapply(physical(fdf2), function(x)attr(attr(x, "physical"), "filename") 
<- sub(path2, path1, filename(x)))
# now we have your situation with broken metadata
# and can fix that by
lapply(physical(fdf2), function(x)attr(attr(x, "physical"), "filename") 
<- sub(path1, path2, filename(x)))
# check

Am 26.06.2015 um 01:04 schrieb Shi, Tao:
> Hi all,
> I'm new to "ff" package through the using Bioconductor package "crlmm".  Here is my problem:
> I've created a few R objects (e.g. an CNSet) using crlmm based on my data and save them in a .RData file.  crlmm heavily uses ff package to store results on a local folder.  For certain reasons, I have moved the ff output folder to somewhere else.  Now when I go back to R, I can't open those CNSet, for example, anymore, as the file has a property still storing the old ff output folder path.
> My question is: is there a quick way to change these paths to the new one, so I don't have to re-run the own analysis.
> Many thanks!
> Tao

More information about the R-sig-hpc mailing list