Tao,
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
jens
library(ff)
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
is.open(fdf1)
is.open(fdf2)
# close the files
close(fdf1)
# and note that
is.open(fdf1)
is.open(fdf2)
# 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
filename(fdf2)
# 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,
filename(x)))
# check this
filename(fdf1)
filename(fdf2)
# filename on ff
filename(fdf1$Species)
# 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,
filename(fdf1$Species))
# now the metadata points to a different location
filename(fdf1$Species)
# note that this physical attribute was also changed
# for the copy
filename(fdf2$Species)
# of course you can fix the erroneous metadata by
attr(attr(fdf1$Species, "physical"), "filename") <- sub(path1, path2,
filename(fdf1$Species))
# 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
open(fdf2)
# and can fix that by
lapply(physical(fdf2), function(x)attr(attr(x, "physical"), "filename")
<- sub(path1, path2, filename(x)))
# check
open(fdf2)
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
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.