Reading and writing vectors extended to handle logical ff vectors as indexes
Package ff
does not allow to extract and set values of ff
vectors based on logical ff
vectors. For this reason
the extractor functions [.ff
and [<-.ff
defined in package ff are overloaded.
If you supply a logical ff
vector as an index to another ff
vector, the overloaded function will convert it to an integer ff
.
index before using the [.ff
and [<-.ff
function from the ff package.
This allows to do ff(1:10)[ff(c(FALSE, TRUE, NA, TRUE))]
Mark that all other functionality from the extractor functions [.ff
and [<-.ff
in package ff are retained. This is an extension
to handle logical ff
vectors as indexes.
## S3 method for class 'ff' x[i, pack = FALSE] ## S3 replacement method for class 'ff' x[i, add = FALSE, pack = FALSE] <- value
x |
an |
i |
missing OR a single index expression OR a |
pack |
FALSE to prevent rle-packing in hybrid index preprocessing, see |
add |
TRUE if the values should rather increment than overwrite at the target positions, see |
value |
the values to be assigned, possibly recycled |
See Extract.ff
. Mark that if a logical ff
vector is used for i
, and if only FALSE
or NA
values are present, NULL is returned in case of the extractor function [.ff
while for the setter function [<-.ff
, if the length value
is zero, this is not allowed.
## extractors x <- ff(1:10) y <- ff(11:20) idx <- ff(c(FALSE, TRUE, NA, TRUE)) x[idx] idx <- ff(c(FALSE, FALSE, TRUE)) x[idx] idx <- ff(1:3) x[idx] ## setters idx <- ff(c(FALSE, TRUE, NA, TRUE)) x[idx] <- y[idx] x idx <- ff(c(FALSE, FALSE, TRUE)) try(x[idx] <- y[idx], silent = T) ## not allowed x idx <- ff(1:3) x[idx] <- y[idx] x
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.