Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

filename

Get or set filename


Description

Get or set filename from ram or ff object via the filename and filename<- generics or rename all files behind a ffdf using the pattern<- generic.

Usage

filename(x, ...)
filename(x, ...) <- value
## Default S3 method:
filename(x, ...)
## S3 method for class 'ff_pointer'
filename(x, ...)
## S3 method for class 'ffdf'
filename(x, ...)
## S3 replacement method for class 'ff'
filename(x, ...) <- value
pattern(x, ...)
pattern(x, ...) <- value
## S3 method for class 'ff'
pattern(x, ...)
## S3 replacement method for class 'ff'
pattern(x, ...) <- value
## S3 replacement method for class 'ffdf'
pattern(x, ...) <- value

Arguments

x

a ram or ff object, or for pattern assignment only - a ffdf object

value

a new filename

...

dummy to keep R CMD CHECK quiet

Details

Assigning a filename<- means renaming the corresponding file on disk - even for ram objects. If that fails, the assignment fails. If a file is moved in or out of getOption("fftempdir") the finalizer is changed accordingly to 'delete' in getOption("fftempdir") and 'close' otherwise.
A pattern is an incomplete filename (optional path and optional filename-prefix) that is turned to filenames by adding a random string using and optionally an extension from optionally an extension from getOption("ffextension") (see fftempfile). filename<- exhibits R's standard behaviour of considering "filename" and "./filename" both to be located in getwd. By constrast pattern<- will create "filename" without path in getOption("fftempdir") and only "./filename" in getwd.

Value

filename and pattern return a character filename or pattern. For ffdf returns a list with one filename element for each physical component. The assignment functions return the changed object, which will keep the change even without re-assigning the return-value

Author(s)

Jens Oehlschlägel

See Also

Examples

## Not run: 
  message("Neither giving pattern nor filename gives a random filename 
with extension ffextension in fftempdir")
  x <- ff(1:12)
  finalizer(x)
  filename(x)
  message("Giving a pattern with just a prefix moves to a random filename 
beginning with the prefix in fftempdir")
  pattern(x) <- "myprefix_"
  filename(x)
  message("Giving a pattern with a path and prefix moves to a random filename 
beginning with prefix in path (use . for getwd) ")
  pattern(x) <- "./myprefix"
  filename(x)
  message("Giving a filename moves to exactly this filename and extension 
in the R-expected place) ")
  if (!file.exists("./myfilename.myextension")){
    filename(x) <- "./myfilename.myextension"
    filename(x)
  }

  message("NOTE that the finalizer has changed from 'delete' to 'close': 
now WE are responsible for deleting the file - NOT the finalizer")
  finalizer(x)
  delete(x)
  rm(x)
  
## End(Not run)

ff

Memory-Efficient Storage of Large Data on Disk and Fast Access Functions

v4.0.4
GPL-2 | GPL-3 | file LICENSE
Authors
Daniel Adler [aut], Christian Gläser [aut], Oleg Nenadic [aut], Jens Oehlschlägel [aut, cre], Martijn Schuemie [aut], Walter Zucchini [aut]
Initial release
2020-10-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.