R 移动ff文件后加载ff对象

R 移动ff文件后加载ff对象,r,ff,R,Ff,我有一个由crlmm包创建的CNSet对象,该对象使用ff包存储 我将其保存为RData文件(使用save功能,而不是ffsave)。然后我不得不将我的ff文件移动到另一个位置。然后我尝试使用load函数加载对象。但是当我访问对象的一部分时,我得到一个错误,即在原始位置找不到aff文件 我使用ldPath函数设置了新的位置,但它仍然在寻找旧的路径 例如: library(ff) ldPath('/new_location') load('object.RData') summary(g) #Wo

我有一个由
crlmm
包创建的
CNSet
对象,该对象使用
ff
包存储

我将其保存为
RData
文件(使用
save
功能,而不是
ffsave
)。然后我不得不将我的
ff
文件移动到另一个位置。然后我尝试使用
load
函数加载对象。但是当我访问对象的一部分时,我得到一个错误,即在原始位置找不到a
ff
文件

我使用
ldPath
函数设置了新的位置,但它仍然在寻找旧的路径

例如:

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:
打开ff/旧/位置/调用D49920A2DF79.ff

错误:file.access(文件名,0)==0不正确

空的


任何帮助都将不胜感激。

您可以使用
物理(x)为
ff
对象
x
指定文件路径
physical(x)
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