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

na.count

Getting and setting 'na.count' physical attribute


Description

The 'na.count' physical attribute gives the current number of NAs if properly initialized and properly maintained, see details.

Usage

## S3 method for class 'ff'
na.count(x, ...)
## Default S3 method:
na.count(x, ...)
## S3 replacement method for class 'ff'
na.count(x, ...) <- value
## Default S3 replacement method:
na.count(x, ...) <- value

Arguments

x

an ff or ram object

...

further arguments (not used)

value

NULL (to remove the 'na.count' attribute) or TRUE to activate or an integer value

Details

The 'na.count' feature is activated by assigning the current number of NAs to na.count(x) <- currentNA and deactivated by assigning NULL. The 'na.count' feature is maintained by the, getset.ff, readwrite.ff and swap, other ff methods for writing – set.ff, [[<-.ff, write.ff, [<-.ff – will stop if 'na.count' is activated. The functions na.count and na.count<- are generic. For ram objects, the default method for na.count calculates the number of NAs on the fly, thus no maintenance restrictions apply.

Value

NA (if set to NULL or NA) or an integer value otherwise

Author(s)

Jens Oehlschlägel, Daniel Adler (C++ back-end)

See Also

getset.ff, readwrite.ff and swap for methods that support maintenance of 'na.count', NA, is.sorted for yet another physical attribute

Examples

message("--- ff examples ---")
  x <- ff(1:12)
  na.count(x)
  message("activate the 'na.count' physical attribute and set the current na.count manually")
  na.count(x) <- 0L
  message("add one NA with a method that maintains na.count")
  swap(x, NA, 1)
  na.count(x)
  message("remove the 'na.count' physical attribute (and stop automatic maintenance)")
  na.count(x) <- NULL
  message("activate the 'na.count' physical attribute and have ff automatically 
calculate the current na.count")
  na.count(x) <- TRUE
  na.count(x)
  message("--- ram examples ---")
  x <- 1:12
  na.count(x)
  x[1] <- NA
  message("activate the 'na.count' physical attribute and have R automatically 
calculate the current na.count")
  na.count(x) <- TRUE
  na.count(x)
  message("remove the 'na.count' physical attribute (and stop automatic maintenance)")
  na.count(x) <- NULL
  na.count(x)
  rm(x); 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.