Reading and writing data.frames (ffdf)
These are the main methods for reading and writing data from ffdf objects.
## S3 method for class 'ffdf' x[i, j, drop = ncols == 1] ## S3 replacement method for class 'ffdf' x[i, j] <- value ## S3 method for class 'ffdf' x[[i, j, exact = TRUE]] ## S3 replacement method for class 'ffdf' x[[i, j]] <- value ## S3 method for class 'ffdf' x$i ## S3 replacement method for class 'ffdf' x$i <- value
x |
an ff object |
i |
a row subscript or a matrix subscript or a list subscript |
j |
a column subscript |
drop |
logical. If TRUE the result is coerced to the lowest possible dimension. The default is to drop if only one column is left, but not to drop if only one row is left. |
value |
A suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If |
exact |
logical: see |
The subscript methods [
, [[
and $
, behave symmetrical to the assignment functions [<-
, [[<-
and $<-
.
What the former return is the assignment value to the latter.
A notable exception is assigning NULL
in [[<-
and $<-
which removes the virtual
column from the ffdf (and the physical
component if it is no longer needed by any virtual column).
Creating new columns via [[<-
and $<-
requires giving a name to the new column (character subscripting). [<-
does not allow to create new columns, only to replace existing ones.
allowed expression | -- | example |
-- | returnvalue |
row selection | x[i, ] |
data.frame or single row as list if drop=TRUE , like from data.frame |
||
column selection | x[ ,i] |
data.frame or single column as vector unless drop=TRUE , like from data.frame |
||
matrix selection | x[cbind(i,j)] |
vector of the integer-matrix indexed cells (if the column types are compatible) | ||
virtual selection | x[i] |
ffdf with the selected columns only |
||
physical selection | x[[i]] |
the selected ff |
||
physical selection | x$i |
the selected ff |
||
Jens Oehlschlägel
d <- data.frame(a=letters, b=rev(letters), c=1:26, stringsAsFactors = TRUE) x <- as.ffdf(d) d[1,] x[1,] d[1:2,] x[1:2,] d[,1] x[,1] d[,1:2] x[,1:2] d[cbind(1:2,2:1)] x[cbind(1:2,2:1)] d[1] x[1] d[[1]] x[[1]] d$a x$a d$a[1:2] x$a[1:2] rm(x); gc()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.