Learn R Programming

annmatrix (version 0.1.2)

convert: Convert annmatrix Objects to and from Other Types

Description

Methods for turning R objects to class annmatrix and vice versa.

Usage

as.annmatrix(x)

# S3 method for default as.annmatrix(x)

# S3 method for matrix as.annmatrix(x)

# S3 method for annmatrix as.matrix(x, ...)

is.annmatrix(x)

Value

is.annmatrix returns TRUE if object is of class 'annmatrix' and FALSE otherwise.

as.annmatrix methods return an object of class 'annmatrix'.

as.matrix returns a regular matrix.

Arguments

x

an R object.

...

additional arguments to be passed to or from methods.

Author

Karolis Koncevičius

Details

as.annmatrix will attempt to convert an object to annmatrix.

as.matrix will turn an annmatrix object into a regular matrix.

is.annmatrix checks if the object is an instance of annmatrix.

Examples

Run this code
# construct annmatrix object
x <- matrix(rnorm(20*10), 20, 10)
X <- as.annmatrix(x)

X$group  <- rep(c("case", "control"), each = 5)
X$gender <- sample(c("M", "F"), 10, replace = TRUE)
X@chr    <- sample(c("chr1", "chr2"), 20, replace = TRUE)
X@pos    <- runif(20, 0, 1000000)

is.matrix(x)
is.matrix(X)

is.annmatrix(x)
is.annmatrix(X)

as.matrix(X)

Run the code above in your browser using DataLab