standardise: Standardise a vector of values to a mean of 0 and standard...

View source: R/standardise.R

standardiseR Documentation

Standardise a vector of values to a mean of 0 and standard deviation of 1

Description

Standardise a vector of values to a mean of 0 and standard deviation of 1

Usage

standardise(x, range = 1:length(x))

Arguments

x

numeric

range

indices for which the mean and standard deviation should be calculated over (default is to use all of 'x')

Value

numeric with standardised value corresponding to each value of 'x'

Author(s)

Andrew Edwards

Examples

## Not run: 
standardise((-5):5)
standardise((-5):5, range = 1:5)   # 3rd value becomes 0
# Say you want to standarised the North Pacific Current Bifurcation Index to
  years only up to and including 2020:
bi_standardise_to_2020 <- dplyr::mutate(bi,
                                        anomaly_2020 = standardise(value,
                                        range = 1:which(bi_new$year == 2020)))
mean(bi_standardise_to_2020$anomaly_2020)   # Not zero because includes
  years after 2020.
mean(dplyr::filter(bi_standardise_to_2020, year <= 2020)$anomaly_2020) # zero

## End(Not run)

pbs-assess/PACea documentation built on April 17, 2025, 11:36 p.m.