Learn R Programming

annmatrix (version 0.1.2)

stack: Stack an annmatrix object

Description

Turns annmatrix into a data frame by transforming the matrix along with row and column annotations into separate data frame columns.

Usage

# S3 method for annmatrix
stack(x, ...)

Value

transposed annmatrix object

Arguments

x

annmatrix object.

...

further arguments passed to or from methods.

Author

Karolis Koncevičius

Examples

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

coldata <- data.frame(group  = rep(c("case", "control"), each = 5),
                      gender = sample(c("M", "F"), 10, replace = TRUE))

rowdata <- data.frame(chr = sample(c("chr1", "chr2"), 20, replace = TRUE),
                      pos = runif(20, 0, 1000000))

X <- annmatrix(x, rowdata, coldata)

# stack all information into a long-format data.frame
Y <- stack(X)

Run the code above in your browser using DataLab