2

I have problem with *.ff files when I ffsave use ffload in R.
When I use ffsave(fileName) I see the fileName.ffData and fileName.RData.

My question are:

  1. Are the *.ff created somewhere when I use ffsave or after I use ffload(fileName)?
  2. Can I delete *.ff files once I see them?
  3. Can I control where to store *.ff files?

Can anyone teach me a proper way to use ffsave and ffload to remove *.ff because they are big files? Thanks.

user1938809
  • 1,135
  • 1
  • 9
  • 12
  • Did you read the [manual](http://cran.r-project.org/web/packages/ff/ff.pdf)? By default normally the files are saved on the working directory, check in the folder of `getwd()`. – llrs Jun 12 '14 at 07:39

1 Answers1

3

Answer to question 3: Can I control where to store *.ff files?

ff files are by default saved in getOption("fftempdir"). You can change this by changing that option

require(ff)
getOption("fftempdir")
[1] "/tmp/RtmpkneHQo"
options(fftempdir = "/home/janw")
x <- ff(1:10)
filename(x)
[1] "/home/janw/ff12153b63d8c1.ff"
list.files("/home/janw", pattern = ".ff")
[1] "ff12153b63d8c1.ff"

Answer to question 2: Can I delete *.ff files once I see them? Of course you can but you might be loosing data which you are using in an R process (every ff object is backed by an .ff file - so if you remove that file, you no longer have the data). But if you have ffsaved the data somewhere, you can safely remove the .ff files as you can load the data again using ffload. See answer to question 1.

Answer to question 1: Are the *.ff created somewhere when I use ffsave or after I use ffload(fileName)? u The .ff files were already on your disk before you called ffsave. What ffsave does is simply zipping the .ff files of the specified objects you indicated to save in a directory. Once you have done this, you can safely remove the .ff files as you can reload them using ffload.

ffsave(x, file = "/home/janw/mydata")
[1] "  adding: home/janw/ff12153b63d8c1.ff (deflated 35%)"
list.files("/home/janw", pattern = ".ff$")
[1] "ff12153b63d8c1.ff"
list.files("/home/janw", pattern = "mydata")
[1] "mydata.ffData" "mydata.RData" 

## Now what happens if we remove the .ff file of the x variable - it is no longer accessible
file.remove("/home/janw/ff12153b63d8c1.ff")
x[1:2]
opening ff /home/janw/ff12153b63d8c1.ff
Error: file.access(filename, 0) == 0 is not TRUE

## And we are ffloading the data back
ffload("/home/janw/mydata", overwrite=TRUE)
[1] "home/janw/ff12153b63d8c1.ff"
## Waw, it is back!
list.files("/home/janw", pattern = ".ff$")
[1] "ff12153b63d8c1.ff"
## And we can access it again.
x[1:2]
opening ff /home/janw/ff12153b63d8c1.ff
[1] 1 2

When ffsaving, you will have a file with extension .ffData and one with .RData. The .ffData file contains the raw .ff files, the .RData file contains the virtual part (levels of factors e.g. and links to the raw .ff files)

  • Please tell me what is wrong with the following code. Thanks. getOption("fftempdir") [1] "/tmp/RtmpORDd7N" getwd() [1] "/u/home/eeskin/yujulee" options(fftempdir = "/u/home/eeskin/yujulee/project") x <- ff(1:10) Error in setwd(dfile) : cannot change working directory – user1938809 Jun 12 '14 at 16:30
  • The directory you specified does not exist on your computer. You need to specify a directory which exists of course. –  Jun 13 '14 at 07:25