Learn R Programming

HDTD (version 1.6.0)

orderdata: Reordering Row and Column Variables

Description

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

Usage

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.

Value

Returns a matrix of the same size as datamat.

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.

See Also

meanmat.ts and meanmat.hat.

Examples

Run this code
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.
ordtissues <- pmatch(tissuesnew,tissuesold)
VEGFmousenew <- orderdata(VEGFmouse,40,order.cols=ordtissues)
colnames(VEGFmousenew)[1:9] 

Run the code above in your browser using DataLab