CentrePerGroup: Centre a data matrix to mean zero (per group)

Description Usage Arguments Value See Also Examples

View source: R/CentrePerGroup.R

Description

Mean centering of an input matrix. When true labels are provided, the groups/clusters are centred individually.

Usage

1
CentrePerGroup(xx, true_labels = numeric(nrow(xx)))

Arguments

xx

The data matrix (n x p).

true_labels

Vector of true cluster assignments. Default: 0 (all elements are treated as belonging to one group).

Value

xx_centred

Mean centred data matrix.

See Also

colMeans, scale

Examples

1
2
3
4
5
6
7
8
  ## 10x5 matrix, 1 group:
  CentrePerGroup(xx=matrix(rnorm(50),10,5))
  
  ## 2 groups:
  CentrePerGroup(xx=matrix(rnorm(50),10,5), true_labels=round(runif(10)))
  
  ## 10 groups:
  CentrePerGroup(xx=matrix(rnorm(5000),100,50), true_labels=round(runif(100)*10))

btaschler/mcap documentation built on May 26, 2019, 1:31 a.m.