I had a CNSet
object created by the crlmm
package that was stored using ff
package.
I saved it as an RData
file (using the save
function, not ffsave
). And then I had to move my ff
files to another location. Then I tried to load the object using the load
function. But when I accessed a part of the object, I'm getting an error that the a ff
file in the original location couldn't be found.
I set the new location using the ldPath
function, but it's still looking in the old path.
Example:
library(ff)
ldPath('/new_location')
load('object.RData')
summary(g)
#Works, print:
#Length Class Mode
#1 CNSet S4
calls(g)[1]
#Raises the next error:
opening ff /old/location/calld49920a2df79.ff
Error: file.access(filename, 0) == 0 is not TRUE
physical(x)
NULL
Any help will be appreciated.
You can specify the file path for ff
object x
with physical(x) <- 'my_file.ff'
. For example:
library(ff)
old <- file.path(tempdir(), 'old.ff') # this will be the original file path
new <- file.path(tempdir(), 'new.ff') # this will be the new file path
x <- ff(1:4, filename=old) # create the original ff file
save(x, file = file.path(tempdir(), 'x.rda')) # save the ff object
close(x) # close the ff object
file.rename(old, new) # rename the file
file.remove(old) # delete the old file
load(file.path(tempdir(), 'x.rda')) # load the ff object
physical(x)$filename <- new # assign the new file path
head(x)
## opening ff C:\Users\John\AppData\Local\Temp\Rtmp2ZEkgw/new.ff
## [1] 1 2 3 4