orderdata: Reordering Row and Column Variables

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/orderdata.R

Description

This utility function rearranges the row and/or the column variables in a desired order.

Usage

1
orderdata(datamat, N, order.rows = NULL, order.cols = NULL)

Arguments

datamat

numeric matrix containing the transposable data.

N

positive integer number indicating the sample size, i.e., the number of subjects.

order.rows

numeric vector displaying the desired order of the row variables.

order.cols

numeric vector displaying the desired order of the column variables.

Details

It is assumed that there are nrow(datamat) row variables and ncol(datamat)/N column variables in datamat. Further, datamat should be written in such a way that every ncol(datamat)/N consecutive columns belong to the same subject and the order of the column variables in each block is preserved across subjects.

Value

Returns a matrix of the same size as datamat.

Author(s)

Anestis Touloumis

See Also

meanmat.ts and meanmat.hat.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(VEGFmouse)
set.seed(1)
tissuesold <-  colnames(VEGFmouse[ ,1:9])
## Suppose that you want to order the tissues in the folowing order.
tissuesnew <- colnames(VEGFmouse[ ,1:9])[sample(9)]
tissuesnew
## To do this, create a numeric vector with the desired order.
ordtis <- pmatch(tissuesnew, tissuesold)
VEGFmousenew <- orderdata(datamat = VEGFmouse, N = 40, order.cols = ordtis)
colnames(VEGFmousenew)[1:9]

HDTD documentation built on Nov. 8, 2020, 8:25 p.m.