Reading and writing data.frames (ffdf)
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.
## S3 method for class 'ffdf' x[i, j, drop = TRUE] ## S3 replacement method for class 'ffdf' x[i, j] <- value
x |
an |
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 |
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.
## 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, ]
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.