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

as.ff

Coercing ram to ff and ff to ram objects


Description

Coercing ram to ff and ff to ram objects while optionally modifying object features.

Usage

as.ff(x, ...)
  as.ram(x, ...)
  ## Default S3 method:
as.ff(x, filename = NULL, overwrite = FALSE, ...)
  ## S3 method for class 'ff'
as.ff(x, filename = NULL, overwrite = FALSE, ...)
  ## Default S3 method:
as.ram(x, ...)
  ## S3 method for class 'ff'
as.ram(x, ...)

Arguments

x

any object to be coerced

filename

path and filename

overwrite

TRUE to overwrite the old filename

...

...

Details

If as.ff.ff is called on an 'ff' object or as.ram.default is called on a non-ff object AND no changes are required, the input object 'x' is returned unchanged. Otherwise the workhorse clone.ff is called. If no change of features are requested, the filename attached to the object remains unchanged, otherwise a new filename is requested (or can be set by the user).

Value

A ram or ff object.

Note

If you use ram <- as.ram(ff) for caching, please note that you must close.ff before you can write back as.ff(ram, overwrite=TRUE) (see examples).

Author(s)

Jens Oehlschlägel

See Also

Examples

message("create ff")
   myintff <- ff(1:12)
   message("coerce (=clone) integer ff to double ff")
   mydoubleff <- as.ff(myintff, vmode="double")
   message("cache (=clone) integer ff to integer ram AND close original ff")
   myintram <- as.ram(myintff) # filename is retained
   close(myintff)
   message("modify ram cache and write back (=clone) to ff")
   myintram[1] <- -1L
   myintff <- as.ff(myintram, overwrite=TRUE)
   message("coerce (=clone) integer ram to double ram")
   mydoubleram <- as.ram(myintram, vmode="double")
   message("coerce (inplace) integer ram to double ram")
   myintram <- as.ram(myintram, vmode="double")
   message("more classic: coerce (inplace) double ram to integer ram")
   vmode(myintram) <- "integer"
   rm(myintff, myintram, mydoubleff, mydoubleram); gc()

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.