pcp_scale | R Documentation |
The function pcp_scale
provides access to a set of transformations to use
in parallel coordinate plots. All transformations other than raw
tend to
produce y values in the interval from 0 and 1.
pcp_scale(data, method = "uniminmax", .by_group = TRUE)
data |
data frame as returned by |
method |
string specifying the method that should be used for scaling the values in a parallel coordinate plot (see Details). |
.by_group |
logical value. If TRUE, scaling will respect any previous grouping variables. Applies to grouped data frames only. |
The data pipeline feeding any of the geom layers in the ggpcp
package is
implemented in a three-step modularized form rather than as the stat
functions more typical for ggplot2
extensions.
The three steps of data pre-processing are:
command | data processing step |
pcp_select | variable selection (and horizontal ordering) |
pcp_scale | (vertical) scaling of values |
pcp_arrange | dealing with tie-breaks on categorical axes |
Note that these data processing steps are executed before the call to ggplot2
and the identity function is used by default in all of the ggpcp
specific layers.
Besides the speed-up by only executing the processing steps once for all layers,
the separation has the additional benefit, that it provides the users with the
possibility to make specific choices at each step in the process. Additionally,
separation allows for a cleaner user interface: parameters affecting the data
preparation process can be moved to the relevant (set of) function(s) only, thereby
reducing the number of arguments without any loss of functionality.
method
is a character string that denotes how to scale the variables
in the parallel coordinate plot. Options are named in the same way as the options in GGally::ggparcoord()
:
raw
: raw data used, no scaling will be done.
std
: univariately, subtract mean and divide by standard deviation. To get values into a unit interval we use a linear transformation of f(y) = y/4+0.5.
robust
: univariately, subtract median and divide by median absolute deviation. To get values into an expected interval of unit interval we use a linear transformation of f(y) = y/4+0.5.
uniminmax
: univariately, scale so the minimum of the variable is zero, and the maximum is one.
globalminmax
: global scaling; the global maximum is mapped to 1,
global minimum across the variables is mapped to 0.
data frame of the same size as the input data; values of pcp_y
and
pcp_yend
are scaled according to the specified method.
pcp_select()
, pcp_arrange()
data(Carcinoma) dim(Carcinoma) # select all variables pcp_data <- Carcinoma |> pcp_select(1:9) summary(pcp_data) pcp_data |> pcp_scale() |> summary() # scaling gets values of pcp_y and pcp_yend between 0 and 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.