Skip to contents

Function to perform mean-centering or median-centering on a numeric matrix or data frame.

Usage

center(x, method = "mean", drop.na = FALSE)

Arguments

x

A numeric matrix or data frame.

method

A character string specifying the centering method, either "mean" or "median".

drop.na

A logical value indicating whether to remove missing values (NA) before centering.

Value

A data frame with the same dimensions as the input, but with columns centered according to the specified method.

Details

Mean-centering calculates the mean of each column and subtracts this from the column. Median-centering is very similar to mean-centering except that the reference point is the median of each column rather than the mean.

Author

Christian L. Goueguel