genescale: Scales a matrix or vector.

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

Description

genescale returns a scaled version of the input matrix m by applying the following formula to each column of the matrix:

y[i] = ( x[i] - min(x) ) / ( max(x) - min(x) )

Usage

1
genescale(m, axis=2, method=c("Z", "R"), na.rm=TRUE)

Arguments

m

Input a matrix or a vector with numeric elements.

axis

An integer indicating which axis of m to scale.

method

Either "Z" or "R", indicating whether a Z scaling or a range scaling should be performed.

na.rm

A boolean indicating whether NA's should be removed.

Details

Either the rows or columns of m are scaled. This is done either by subtracting the mean and dividing by the standard deviation ("Z") or by subtracing the minimum and dividing by the range.

Value

A scaled version of the input. If m is a matrix or a dataframe then the dimensions of the returned value agree with that of m, in both cases the returned value is a matrix.

Author(s)

R. Gentleman

See Also

genefinder,scale

Examples

1
2
  m <- matrix(1:12, 4, 3)
  genescale(m)

Example output

           [,1]       [,2]       [,3]
[1,] -1.1618950 -1.1618950 -1.1618950
[2,] -0.3872983 -0.3872983 -0.3872983
[3,]  0.3872983  0.3872983  0.3872983
[4,]  1.1618950  1.1618950  1.1618950

genefilter documentation built on Jan. 23, 2021, 2:01 a.m.