dimRedData-class {dimRed} | R Documentation |
Class "dimRedData"
Description
A class to hold data for dimensionality reduction and methods.
Usage
## S4 method for signature 'dimRedData'
as.data.frame(x, meta.prefix = "meta.", data.prefix = "")
## 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)
Arguments
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. |
object |
Of class dimRedData. |
i |
a valid index for subsetting rows. |
Details
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
.
Methods (by generic)
-
as.data.frame
: convert to data.frame -
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.
Slots
data
of class
matrix
, holds the data, observations in rows, variables in columnsmeta
of 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 thedata
slot or be an empty data frame.
See Also
Other dimRedData:
as.dimRedData()
Other dimRedData:
as.dimRedData()
Examples
## 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, ]
## Shuffle data:
s3 <- s3d[nrow(s3d)]
## Get the number of variables:
ndims(s3d)