Learn R Programming

ribiosUtils (version 1.7.7)

rowscale.table: Scale a table by row

Description

Scaling a table by row can be slightly slower due to a transposing step.

Usage

# S3 method for table
rowscale(x, center = TRUE, scale = TRUE)

Value

A table with each row scaled.

Arguments

x

An matrix

center

Logical, passed to scale. to TRUE

scale

Logical, passed to scale. TRUE

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

Examples

Run this code

letterDf <- data.frame(from=c("A", "A", "B", "C"), to=c("A", "B", "C", "A"))
tbl <- table(letterDf$from, letterDf$to)
tblRowscale <- rowscale(tbl)

print(tbl)
print(tblRowscale)
rowMeans(tblRowscale)
apply(tblRowscale, 1L, sd)

rowscale(tbl, center=FALSE, scale=FALSE) ## equal to mat
rowscale(tbl, center=TRUE, scale=FALSE)
rowscale(tbl, center=FALSE, scale=TRUE)

Run the code above in your browser using DataLab