ffextract: Reading and writing vectors extended to handle logical 'ff'...

Description Usage Arguments Value See Also Examples

Description

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.

Usage

1
2
3
4
5
## S3 method for class 'ff'
 x[i, pack = FALSE]

## S3 replacement method for class 'ff'
 x[i, add = FALSE, pack = FALSE] <- value

Arguments

x

an ff object

i

missing OR a single index expression OR a hi object

pack

FALSE to prevent rle-packing in hybrid index preprocessing, see as.hi

add

TRUE if the values should rather increment than overwrite at the target positions, see readwrite.ff

value

the values to be assigned, possibly recycled

Value

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.

See Also

Extract.ff

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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

ffbase documentation built on Feb. 27, 2021, 5:06 p.m.