filename | R Documentation |
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.
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
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 |
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
.
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
Jens Oehlschlägel
fftempfile
, finalizer
, ff
, as.ff
, as.ram
, update.ff
, file.move
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.