pcp_scale {ggpcp}R Documentation

Data wrangling for GPCPs: Step 2 scale values

Description

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.

Usage

pcp_scale(data, method = "uniminmax", .by_group = TRUE)

Arguments

data

data frame as returned by select_pcp

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.

Details

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():

Value

data frame of the same size as the input data; values of pcp_y and pcp_yend are scaled according to the specified method.

See Also

pcp_select(), pcp_arrange()

Examples

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

[Package ggpcp version 0.2.0 Index]