ffextractffdf: Reading and writing data.frames (ffdf)

Description Usage Arguments Value See Also Examples

Description

Package ff does not allow to extract and set values of ffdf objects based on logical ff vectors. For this reason the extractor functions [.ffdf and [<-.ffdf defined in package ff are overloaded.
If you supply a logical ff vector as an index to subset an ffdf object, the overloaded function will convert the logical ff vector to an integer ff index before using the [.ffdf and [<-.ffdf functions from the ff package.
This allows to do as.ffdf(iris)[as.ff(iris$Sepal.Length > 5), ]

This is an extension to handle logical ff vectors as indexes to ffdf objects.

Usage

1
2
3
4
5
## S3 method for class 'ffdf'
 x[i, j, drop = TRUE]

## S3 replacement method for class 'ffdf'
 x[i, j] <- value

Arguments

x

an ff object

i

a row subscript

j

a column subscript

drop

logical. If TRUE the result is coerced to the lowest possible dimension.

value

A suitable replacement value

Value

See Extract.ffdf. Mark that if a logical ff vector is used for i, and if only FALSE or NA values are present, this is not allowed as ffdf with zero rows do not exist.

See Also

Extract.ffdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## extractors for ffdf objects
data(iris)
x <- as.ffdf(iris)
x[x$Sepal.Length > 5, ]
x[x$Sepal.Length > 5, 1:3]
x[x$Sepal.Length > 5, 1, drop=TRUE]
x[x$Sepal.Length > 5, 1]
x[, 1]
x[, ]
x[c("Sepal.Length", "Sepal.Width")]
x[1:2]

## setters
data(iris)
x <- as.ffdf(iris)
testpositions <- x$Sepal.Length > 5
testpositions <- ffwhich(testpositions, testpositions == TRUE)
mynewdata <- x[testpositions, c("Sepal.Length", "Sepal.Width")]
mynewdata$Sepal.Length <- ff(1, length = nrow(mynewdata))
x[x$Sepal.Length > 5, c("Sepal.Length", "Sepal.Width")] <- mynewdata
x[testpositions, ]

data(iris)
x <- as.ffdf(iris)
testpositions <- x$Sepal.Length > 5
testpositions <- ffwhich(testpositions, testpositions == TRUE)
mynewdata <- x[testpositions, c("Sepal.Length", "Sepal.Width")]
mynewdata$Sepal.Length <- ff(1, length = nrow(mynewdata))
x[testpositions, c("Sepal.Length", "Sepal.Width")] <- mynewdata
x[testpositions, ]

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