Learn R Programming

dimRed (version 0.2.5)

dimRedData-class: Class "dimRedData"

Description

A class to hold data for dimensionality reduction and methods.

Usage

# S4 method for dimRedData
as.data.frame(x, meta.prefix = "meta.", data.prefix = "")

# S4 method for dimRedData getData(object)

# S4 method for dimRedData getMeta(object)

# S4 method for dimRedData nrow(x)

# S4 method for dimRedData,ANY,ANY,ANY [(x, i)

# S4 method for 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.

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 columns

meta

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 the data slot or be an empty data frame.

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.

See Also

Other dimRedData: as.dimRedData()

Other dimRedData: as.dimRedData()

Examples

Run this code
## 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)

Run the code above in your browser using DataLab