View source: R/S3_aggregations.R
| scale | R Documentation |
Block-wise centering and scaling equivalent to base R scale().
The computation runs entirely on disk — the full matrix is never loaded into
RAM.
## S3 method for class 'HDF5Matrix'
scale(
x,
center = TRUE,
scale = TRUE,
byrows = FALSE,
wsize = NULL,
result_path = NULL,
compression = NULL,
...
)
x |
An |
center |
Logical (or numeric vector, see Details). If |
scale |
Logical (or numeric vector, see Details). If |
byrows |
Logical. If |
wsize |
Integer or NULL. Block size for HDF5 reads (NULL = auto). |
result_path |
Output location. |
compression |
Integer (0-9) or NULL. gzip compression level for the
result datasets. NULL uses the global option set by
|
... |
Ignored (for S3 compatibility). |
Passing a pre-computed numeric vector as center or scale is
not currently supported. If a vector is supplied it is coerced to a logical
(TRUE if length(x) > 0) and a warning is issued.
The returned HDF5Matrix carries scaled:center and
scaled:scale attributes (numeric vectors), mirroring the behavior of
base::scale().
An HDF5Matrix pointing to the normalized dataset on disk.
tmp <- tempfile(fileext = ".h5")
X <- hdf5_create_matrix(tmp, "data/M",
data = matrix(rnorm(500), 50, 10))
Xs <- scale(X) # center=TRUE, scale=TRUE by cols
cat("scaled:center[1]:", attr(Xs, "scaled:center")[1], "\n")
X$close(); Xs$close(); unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.