Description Usage Arguments Details Value Methods (by class) Deviations Reference
Given a numeric vector, convert the numbers to z scores or robust z scores. The function accepts raw values as well as normalized ones.
1 2 3 4 5 6 7 8 9 10 | zscore(x, ...)
## Default S3 method:
zscore(x, robust = TRUE, deviations = FALSE, reference, ...)
## S3 method for class 'data.frame'
zscore(x, robust = TRUE, deviations = FALSE, reference, variables, ...)
## S3 method for class 'grouped_df'
zscore(x, robust = TRUE, deviations = FALSE, reference, variables, ...)
|
x |
a numeric vector |
... |
arguments passed to methods |
robust |
logical flag whether to calculate normal or robust z scores |
deviations |
logical flag whether the supplied data is raw or normalized |
reference |
optional determination of reference observations;
for the default method, a logical vector;
for the data frame method, a logical vector
or any predicate (bare or as string) that refers to |
variables |
for data frame method, character vector of variables to standardize |
The z score is a data point standardized to the distribution it comes from. It is a measure of the deviation of the point from the distribution's location parameter expressed in terms of the dispersion parameter of that distribution.
For a normal z score the difference between a point and the distribution mean is divided by the distribution's standard deviation. For a robust z score the mean and standard deviation are replaced by the median and median absolute deviation, respectively.
a numeric vector of z scores or a data frame with added columns of z scores
default
: for numeric vectors
data.frame
: calculates zscores for requested variables in a data frame
grouped_df
: see data.frame__to__grouped_df
Data is accepted as raw or normalized and the function can be informed of this with a logical flag. For deviations the location parameter is assumed to be 0. If normalization is done by simply subtracting the mean/median of the whole sample from each data point, this is redundant but other normalization methods may introduce differences differences.
Data points in the sample can be standardized against part of the distribution rather than the whole. Should this be the case, supply a logical vector (or predicate that will be evaluated within the data frame) to determine the reference subpopulation.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.