diff --git a/DESCRIPTION b/DESCRIPTION index b62bff2..85e3de0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,7 @@ License: GPL-3 Imports: ggplot2 (>= 3.2.0), dplyr (>= 0.8.3), - tidyselect (>= 0.2.5), + tidyselect (>= 1.0.0), tidyr (>= 0.8.3), assertthat, rlang (>= 0.4.0), diff --git a/NAMESPACE b/NAMESPACE index ca4f09f..9c8440e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,5 +24,6 @@ importFrom(stats,mad) importFrom(stats,median) importFrom(tidyr,gather) importFrom(tidyr,spread) +importFrom(tidyselect,eval_select) importFrom(tidyselect,vars_select) importFrom(utils,getFromNamespace) diff --git a/R/layers.R b/R/layers.R index 443891e..c428208 100644 --- a/R/layers.R +++ b/R/layers.R @@ -16,7 +16,7 @@ compute_aesthetics_pcp <- function(self, data, plot) { #' function to setup the vars mapping in pcps #' @noRd -#' @importFrom tidyselect vars_select +#' @importFrom tidyselect vars_select eval_select #' @importFrom dplyr tbl_vars #' @importFrom rlang eval_tidy #' @importFrom utils getFromNamespace @@ -34,8 +34,9 @@ setup_layer_pcp <- function(self, data, plot) { aes_vars <- rlang::eval_tidy(plot$mapping$vars) # browser() + idx <- unlist(lapply(aes_vars, eval_select, data = data)) - idx <- unlist(lapply(aes_vars, getFromNamespace("eval_select","tidyselect"), data = data)) +# idx <- unlist(lapply(aes_vars, getFromNamespace("eval_select","tidyselect"), data = data)) # idx <- getFromNamespace("vars_select_eval","tidyselect")(names(data), aes_vars) aes_vars <- names(idx) diff --git a/docs/articles/ggpcp.html b/docs/articles/ggpcp.html index 01d101c..511c47b 100644 --- a/docs/articles/ggpcp.html +++ b/docs/articles/ggpcp.html @@ -85,7 +85,7 @@
mpg
, cyl
, mpg:cyl
, sex
, age
start_with("male")
, see ?tidyselect::select_helpers
+start_with("male")
, see ?tidyselect::select_helpers
An example:
@@ -313,6 +313,7 @@The parallel coordinate plot displays multiple y-axes, and shows the observations across several dimensions as lines. This function work well with both numeric and categorical variables at the same time after proper scaling.
-geom_pcp(mapping = NULL, data = NULL, stat = "pcp", position = "identity", ..., method = "uniminmax", freespace = 0.1, boxwidth = 0, rugwidth = 0, interwidth = 1, breakpoint = NULL, - overplot = "original", mirror = FALSE, arrow = NULL, + overplot = "hierarchical", mirror = FALSE, arrow = NULL, arrow.fill = NULL, lineend = "butt", linejoin = "round", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)- +
method
is a character string that denotes how to scale the variables
@@ -257,7 +257,6 @@
smallfirst
: smaller groups of lines are drawn first, placing large groups of lines on top.
largefirst
: larger groups of lines are drawn first, placing small groups of lines on top.
library(ggplot2) @@ -284,9 +283,7 @@Examp
Contents
diff --git a/docs/reference/geom_pcp_band-1.png b/docs/reference/geom_pcp_band-1.png index b666024..7b73788 100644 Binary files a/docs/reference/geom_pcp_band-1.png and b/docs/reference/geom_pcp_band-1.png differ diff --git a/docs/reference/geom_pcp_band.html b/docs/reference/geom_pcp_band.html index a4c6d31..ad59e54 100644 --- a/docs/reference/geom_pcp_band.html +++ b/docs/reference/geom_pcp_band.html @@ -8,11 +8,13 @@Bands for the parallel coordinate plot — geom_pcp_band • ggpcp + + @@ -30,13 +32,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -103,16 +105,14 @@Bands for the parallel coordinate plot
-To add bands from factor to factor
-geom_pcp_band(mapping = NULL, data = NULL, stat = "pcpband", position = "identity", ..., freespace = 0.1, boxwidth = 0, rugwidth = 0, interwidth = 1, breakpoint = NULL, merge = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)- +Arguments
library(ggplot2) @@ -223,7 +223,6 @@Examp
Contents
diff --git a/docs/reference/geom_pcp_box-1.png b/docs/reference/geom_pcp_box-1.png index b666024..7b73788 100644 Binary files a/docs/reference/geom_pcp_box-1.png and b/docs/reference/geom_pcp_box-1.png differ diff --git a/docs/reference/geom_pcp_box.html b/docs/reference/geom_pcp_box.html index 687cf80..6d2d962 100644 --- a/docs/reference/geom_pcp_box.html +++ b/docs/reference/geom_pcp_box.html @@ -8,11 +8,13 @@Boxes for the levels in each factor variable in parallel coordinate plot — geom_pcp_box • ggpcp + + @@ -30,13 +32,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -103,16 +105,14 @@Boxes for the levels in each factor variable in parallel coordinate plot
-To add boxes showing the levels in each factor variable
-geom_pcp_box(mapping = NULL, data = NULL, stat = "pcpbox", position = "identity", rule = "evenodd", ..., freespace = 0.1, boxwidth = 0, rugwidth = 0, interwidth = 1, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)- +Arguments
- +
@@ -198,7 +198,7 @@ Arg the default plot specification, e.g. [borders()].
Examples
library(ggplot2) @@ -219,7 +219,6 @@Examp
Contents
diff --git a/docs/reference/geom_pcp_text-1.png b/docs/reference/geom_pcp_text-1.png index b666024..7b73788 100644 Binary files a/docs/reference/geom_pcp_text-1.png and b/docs/reference/geom_pcp_text-1.png differ diff --git a/docs/reference/geom_pcp_text.html b/docs/reference/geom_pcp_text.html index 0dcbc64..3f81183 100644 --- a/docs/reference/geom_pcp_text.html +++ b/docs/reference/geom_pcp_text.html @@ -8,11 +8,13 @@Texts and labels for the categories of factor variables in parallel coordinate plot — geom_pcp_label • ggpcp + + @@ -30,13 +32,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -103,9 +105,7 @@Texts and labels for the categories of factor variables in parallel coordina
-To add texts and labels in boxes showing the levels in each factor variable
-geom_pcp_label(mapping = NULL, data = NULL, stat = "pcpbox", @@ -120,7 +120,7 @@- +Texts and labels for the categories of factor variables in parallel coordina rugwidth = 0, interwidth = 1, parse = FALSE, nudge_x = 0, nudge_y = 0, check_overlap = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
Arguments
- +
@@ -226,7 +226,7 @@ Arg same layer will not be plotted.
Examples
library(ggplot2) @@ -247,7 +247,6 @@Examp
Contents
diff --git a/docs/reference/index.html b/docs/reference/index.html index 7b8b4c6..e509f26 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -8,11 +8,13 @@Function reference • ggpcp + + @@ -30,10 +32,12 @@ + + @@ -79,7 +83,6 @@ Reference - @@ -142,6 +145,12 @@nasa
+ NASA - Data Expo 2006
+ + diff --git a/docs/reference/nasa.html b/docs/reference/nasa.html index 228a65d..30ae458 100644 --- a/docs/reference/nasa.html +++ b/docs/reference/nasa.html @@ -8,11 +8,13 @@+ + +Parallel coordinate plot for both numeric and categorical data
NASA - Data Expo 2006 — nasa • ggpcp + + @@ -30,8 +32,8 @@ - + @@ -87,7 +90,6 @@ Reference - @@ -108,26 +110,23 @@NASA - Data Expo 2006
-The data are geographic and atmospheric measures on a very coarse 24 by 24 grid covering Central America. This data was provided by the NASA Langley Research Center Atmospheric Sciences Data Center as part of the ASA Data Expo in 2006. Monthly averages of a set of atmospheric measurements are provided for Jan 1995 to Dec 2000. A subset of this data is available from the `GGally` package.
-nasa
- + +Format
A data frame with 41472 (= 24 x 24 x 72) rows and 15 variables:
-Source
http://stat-computing.org/dataexpo/2006/
-Structural variables
@@ -138,7 +137,6 @@Measured variables
@@ -148,7 +146,6 @@Examples
data(nasa) @@ -163,15 +160,10 @@Examp
-The parallel coordinate plot displays multiple y-axes, and shows the observations across several dimensions as ploi-lines. This function work well with both numeric and categorical variables at the same time after proper scaling.
-stat_pcp(mapping = NULL, data = NULL, geom = "segment", - position = "identity", ..., freespace = 0.1, boxwidth = 0, - rugwidth = 0, interwidth = 1, breakpoint = NULL, na.rm = FALSE, - show.legend = NA, inherit.aes = TRUE)- + position = "identity", ..., freespace = 0.1, method = "uniminmax", + boxwidth = 0, rugwidth = 0, interwidth = 1, breakpoint = NULL, + overplot = "hierarchical", mirror = FALSE, na.rm = FALSE, + show.legend = NA, inherit.aes = TRUE) + +StatPcp +Arguments
Format
+ +An object of class
+StatPcp
(inherits fromStat
,ggproto
,gg
) of length 6.Details
+ +
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 `ggparcoord` (GGally):+
+- +
raw
: raw data used, no scaling will be done.- +
std
: univariately, subtract mean and divide by standard deviation. To get values into a [0,1] 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 a [0,1] 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
: gobal scaling; the global maximum is mapped to 1, + global minimum across the variables is mapped to 0.
overplot
is a character string that denotes how to conduct overplotting +in the parallel coordinate plot. The lines fromgeom_pcp()
are drawn according to the order they shown in your data set in default. +Note that this argument provides a framework, the order in the original data still has a role in overplotting, +especially for lines outside factor blocks(forhierarchical
only), plots withbreakpoint
turned on(for methods excepthierarchical
):+
- +
original
: use the original order, first shown first drawn.- +
hierarchical
: hierarchically drawn according to the combinations of levels of factor variables, + which will change according to different level structures of factor variables you provided. + This was done separately for each factor block. The right most factor variables have the largest weight across a sequence of factor variables, + the last level of a factor variable has the largest weight within a factor variable. + Groups of lines with larger weight will be drawn on top. Lines outside of factor blocks still use the original order, which is different from other methods.- +
smallfirst
: smaller groups of lines are drawn first, placing large groups of lines on top.- +
largefirst
: larger groups of lines are drawn first, placing small groups of lines on top.