Getting and setting 'na.count' physical attribute
na.count.rdThe '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 method for class 'ff'
na.count(x, ...) <- value
# Default S3 method
na.count(x, ...) <- valueDetails
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.
Examples
message("--- ff examples ---")
#> --- ff examples ---
x <- ff(1:12)
na.count(x)
#> [1] NA
message("activate the 'na.count' physical attribute and set the current na.count manually")
#> 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")
#> add one NA with a method that maintains na.count
swap(x, NA, 1)
#> [1] 1
na.count(x)
#> [1] 1
message("remove the 'na.count' physical attribute (and stop automatic maintenance)")
#> 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")
#> activate the 'na.count' physical attribute and have ff automatically
#> calculate the current na.count
na.count(x) <- TRUE
na.count(x)
#> [1] 1
message("--- ram examples ---")
#> --- ram examples ---
x <- 1:12
na.count(x)
#> [1] NA
x[1] <- NA
message("activate the 'na.count' physical attribute and have R automatically
calculate the current na.count")
#> activate the 'na.count' physical attribute and have R automatically
#> calculate the current na.count
na.count(x) <- TRUE
na.count(x)
#> [1] 1
message("remove the 'na.count' physical attribute (and stop automatic maintenance)")
#> remove the 'na.count' physical attribute (and stop automatic maintenance)
na.count(x) <- NULL
na.count(x)
#> [1] NA
rm(x); gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1252231 66.9 2239654 119.7 2239654 119.7
#> Vcells 2306062 17.6 8388608 64.0 8387257 64.0