Learn R Programming

maSigPro (version 1.44.0)

average.rows: Average rows by match and index

Description

average.rows matches rownames of a matrix to a match vector and performs averaging of the rows by the index provided by an index vector.

Usage

average.rows(x, index, match, r = 0.7)

Arguments

x
a matrix
index
index vector indicating how rows must be averaged
match
match vector for indexing rows
r
minimal correlation value between rows to compute average

Value

a matrix of averaged rows

Details

rows will be averaged only if the pearson correlation coefficient between all rows of each given index is greater than r. If not, that group of rows is discarded in the result matrix.

Examples

Run this code

## create data matrix for row averaging
x <- matrix(rnorm(30), nrow = 6,ncol = 5)
rownames(x) <- paste("ID", c(1, 2, 11, 12, 19, 20), sep = "")
i <- paste("g", rep(c(1:10), each = 2), sep = "")  # index vector
m <- paste("ID", c(1:20), sep = "")  # match vector
average.rows(x, i, m, r = 0) 

Run the code above in your browser using DataLab