| dimRedData-class {dimRed} | R Documentation |
A class to hold data for dimensionality reduction and methods.
## S4 method for signature 'dimRedData' as.data.frame(x, meta.prefix = "meta.", data.prefix = "") ## S4 method for signature 'formula' as.dimRedData(formula, data) ## S4 method for signature 'dimRedData' getData(object) ## S4 method for signature 'dimRedData' getMeta(object) ## S4 method for signature 'dimRedData' nrow(x) ## S4 method for signature 'dimRedData,ANY,ANY,ANY' x[i] ## S4 method for signature 'dimRedData' ndims(object)
x |
Of class dimRedData |
meta.prefix |
Prefix for the columns of the meta data names. |
data.prefix |
Prefix for the columns of the variable names. |
formula |
The formula, left hand side is assigned to the meta slot right hand side is assigned to the data slot. |
data |
A data frame |
object |
Of class dimRedData. |
i |
a valid index for subsetting rows. |
The class hast two slots, data and meta. The
data slot contains a numeric matrix with variables in
columns and observations in rows. The meta slot may contain
a data.frame with additional information. Both slots need to
have the same number of rows or the meta slot needs to
contain an empty data.frame.
See examples for easy conversion from and to data.frame.
For plotting functions see plot.dimRedData.
as.data.frame: convert to data.frame
as.dimRedData: Convert a data.frame to a dimRedData
object using a formula
getData: Get the data slot.
getMeta: Get the meta slot.
nrow: Get the number of observations.
[: Subset rows.
ndims: Extract the number of Variables from the data.
dataof class matrix, holds the data, observations in
rows, variables in columns
metaof class data.frame, holds meta data such as
classes, internal manifold coordinates, or simply additional
data of the data set. Must have the same number of rows as the
data slot or be an empty data frame.
## Load an example data set:
s3d <- loadDataSet("3D S Curve")
## Create using a constructor:
### without meta information:
dimRedData(iris[, 1:4])
### with meta information:
dimRedData(iris[, 1:4], iris[, 5])
### using slot names:
dimRedData(data = iris[, 1:4], meta = iris[, 5])
## Convert to a dimRedData objects:
Iris <- as(iris[, 1:4], "dimRedData")
## Convert to data.frame:
head(as(s3d, "data.frame"))
head(as.data.frame(s3d))
head(as.data.frame(as(iris[, 1:4], "dimRedData")))
## Extract slots:
head(getData(s3d))
head(getMeta(s3d))
## Get the number of observations:
nrow(s3d)
## Subset:
s3d[1:5, ]
## create a dimRedData object using a formula
as.dimRedData(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
iris)[1:5]
## Shuffle data:
s3 <- s3d[nrow(s3d)]
## Get the number of variables:
ndims(s3d)