Git Product home page Git Product logo

ggasym's Introduction

ggasym

License: GPL v3 CRAN status CRAN downloads R build status Coverage status

Asymmetric Matrix Plotting in ‘ggplot’

‘ggasym’ (pronounced “gg-awesome”) plots a symmetric matrix with three different fill aesthetics for the top-left and bottom-right triangles and along the diagonal. It operates within the Grammar of Graphics paradigm implemented in ‘ggplot2’.

Checkout the documentation and vignettes at the pkgdown website https://jhrcook.github.io/ggasym/

For information on using ‘ggplot2’, start here.

Download and Installation

‘ggasym’ is available on CRAN. Use the following command to install.

install.packages("ggasym")

You can download and install the latest development version from the GitHub repo.

devtools::install_github("jhrcook/ggasym")

And load the package with the standard library function.

library(ggasym)

Basic Usage

Here is a basic example. tib is a “tibble” (i.e.. fancy “data.frame”) of comparisons between groups “A” through “E”. There are two values to be plotted, val_1 and val_2, that hold data on the comparison between g1 and g2. tib is first passed to asymmetrise() to fill in all the missing combinations between g1 and g2 such that the symmetric matrix can be built. All added values take the value NA. The modified data table is finally passed to ggplot() and geom_asymmat() is added on. Here, asymmetrise() added the rows where g1 and g2 are equal, thus will fill the diagonal. I set these values to val_3.

tib <- tibble(
  g1 = c("A", "A", "A", "A", "B", "B", "B", "C", "C", "D"),
  g2 = c("B", "C", "D", "E", "C", "D", "E", "D", "E", "E"),
  val_1 = seq(1, 10, 1),
  val_2 = rnorm(10, mean = 0, sd = 3)
)
tib <- asymmetrise(tib, g1, g2)
tib$val_3 <- runif(nrow(tib))
ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(fill_tl = val_1, fill_br = val_2, fill_diag = val_3)) +
  scale_fill_tl_gradient(low = "lightpink", high = "tomato") +
  scale_fill_br_gradient(low = "lightblue1", high = "dodgerblue") +
  scale_fill_diag_gradient(low = "yellow", high = "orange3")

New Aesthetics

The new aesthetics fill_tl, fill_br, and fill_diag behave just like the normal fill, except that they correspond to the top-left (“tl”) and bottom-right (“br”) triangles of the matrix, respectively. This package also includes analogous functions for scaling the fill colors such as scale_fill_tl_gradient2() and scale_fill_br_gradientn() that operate just as expected when using ‘ggplot2’.

ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(fill_tl = val_1, fill_br = val_2, fill_diag = val_3)) +
  scale_fill_tl_gradient(low = "lightpink", high = "tomato") +
  scale_fill_br_gradient2(low = "orange", mid = "white", high = "dodgerblue") +
  scale_fill_diag_gradientn(colors = rainbow(25))

Adjusting Colorbars

Of note, with three colorbars, it may be useful to control their position and other properties. This can be done just like normal in ‘ggplot2’ by passing the correct values to the guide parameter in scale_fill_*_gradient() (original documentation). Below are a few of the options where I put the bars horizontal, adjust the ordering, and put the title above each.

ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(fill_tl = val_1, fill_br = val_2, fill_diag = val_3)) +
  scale_fill_tl_gradient(
    low = "lightpink", high = "tomato",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 1,
      title.position = "top"
    )
  ) +
  scale_fill_br_gradient2(
    low = "orange", mid = "white", high = "dodgerblue",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 3,
      title.position = "top"
    )
  ) +
  scale_fill_diag_gradientn(
    colors = rainbow(25),
    guide = guide_colourbar(
      direction = "horizontal",
      order = 2,
      title.position = "top"
    )
  )

Full ggplot2 integration

Since the new geom is a normal ‘ggplot2’ object, it can be introduced into a standard ‘ggplot2’ workflow. Note that the labels can be adjusted like normal using the labs function and using the fill_tl, fill_br, and fill_diag arguments.

ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(
    fill_tl = log(val_1),
    fill_br = val_2,
    fill_diag = val_3
  )) +
  scale_fill_tl_gradient(
    low = "lightpink", high = "tomato",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 1,
      title.position = "top"
    )
  ) +
  scale_fill_br_gradient(
    low = "lightblue1", high = "dodgerblue",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 3,
      title.position = "top"
    )
  ) +
  scale_fill_diag_gradient(
    low = "grey80", high = "grey20",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 2,
      title.position = "top"
    )
  ) +
  labs(
    fill_tl = "top-left fill",
    fill_br = "bottom-right fill",
    fill_diag = "diagonal fill",
    title = "Example of ggasym"
  ) +
  theme_bw() +
  theme(
    axis.title = element_blank(),
    plot.title = element_text(hjust = 0.5),
    panel.background = element_rect(fill = "grey70"),
    panel.grid = element_blank()
  ) +
  scale_x_discrete(expand = c(0, 0)) +
  scale_y_discrete(expand = c(0, 0))

Faceting

If you have multiple categories, faceting works as expected. The only difference is in the preparation of the data table: you must group_by() the value(s) you will facet by before passing to asymmetrise(). This is shown below.

tib <- tibble(
  g1 = rep(c("A", "A", "B"), 2),
  g2 = rep(c("B", "C", "C"), 2),
  val_1 = seq(1, 6),
  val_2 = rnorm(6),
  grps = c(1, 1, 1, 2, 2, 2)
)
tib
#> # A tibble: 6 x 5
#>   g1    g2    val_1   val_2  grps
#>   <chr> <chr> <int>   <dbl> <dbl>
#> 1 A     B         1  0.0746     1
#> 2 A     C         2 -1.99       1
#> 3 B     C         3  0.620      1
#> 4 A     B         4 -0.0561     2
#> 5 A     C         5 -0.156      2
#> 6 B     C         6 -1.47       2

Grouping first by grps, the tibble is asymmetrized while retaining the grps assignments. I then added values to the diagonal.

tib <- tib %>%
  group_by(grps) %>%
  asymmetrise(g1, g2) %>%
  ungroup()
tib <- tib %>% mutate(val_3 = ifelse(g1 == g2, runif(nrow(tib)), NA))
tib
#> # A tibble: 18 x 6
#>     grps g1    g2    val_1   val_2  val_3
#>    <dbl> <chr> <chr> <int>   <dbl>  <dbl>
#>  1     1 A     B         1  0.0746 NA
#>  2     1 A     C         2 -1.99   NA
#>  3     1 B     C         3  0.620  NA
#>  4     1 B     A         1  0.0746 NA
#>  5     1 C     A         2 -1.99   NA
#>  6     1 C     B         3  0.620  NA
#>  7     1 A     A        NA NA       0.459
#>  8     1 B     B        NA NA       0.332
#>  9     1 C     C        NA NA       0.651
#> 10     2 A     B         4 -0.0561 NA
#> 11     2 A     C         5 -0.156  NA
#> 12     2 B     C         6 -1.47   NA
#> 13     2 B     A         4 -0.0561 NA
#> 14     2 C     A         5 -0.156  NA
#> 15     2 C     B         6 -1.47   NA
#> 16     2 A     A        NA NA       0.839
#> 17     2 B     B        NA NA       0.347
#> 18     2 C     C        NA NA       0.334
ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(
    fill_tl = log(val_1),
    fill_br = val_2,
    fill_diag = val_3
  )) +
  scale_fill_tl_gradient(
    low = "lightpink", high = "tomato",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 1,
      title.position = "top"
    )
  ) +
  scale_fill_br_gradient(
    low = "lightblue1", high = "dodgerblue",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 3,
      title.position = "top"
    )
  ) +
  scale_fill_diag_gradient(
    low = "grey80", high = "grey20",
    guide = guide_colourbar(
      direction = "horizontal",
      order = 2,
      title.position = "top"
    )
  ) +
  labs(
    fill_tl = "top-left fill",
    fill_br = "bottom-right fill",
    fill_diag = "diagonal fill",
    title = "Example of faceting with ggasym"
  ) +
  theme_bw() +
  theme(
    axis.title = element_blank(),
    plot.title = element_text(hjust = 0.5),
    panel.background = element_rect(fill = "grey70"),
    panel.grid = element_blank()
  ) +
  scale_x_discrete(expand = c(0, 0)) +
  scale_y_discrete(expand = c(0, 0)) +
  facet_grid(. ~ grps)


Statistical Test Wrapper

I created a wrapper for handling the results of a statistical test to produce a tibble ready to be plotted with ggasym. Here is a brief example - a more detailed example is shown in the vignette “Statistical Test Plotting”. Here I test if the median sale price of houses in Austin, Texas is different between any of the years (for more information on the data source: ?ggplot2::txhousing).

tib <- ggplot2::txhousing %>%
  filter(city == "Austin") %>%
  mutate(year = as.character(year))
aov_res <- aov(median ~ year, data = tib)
broom::tidy(aov_res)
#> # A tibble: 2 x 6
#>   term         df         sumsq       meansq statistic    p.value
#>   <chr>     <dbl>         <dbl>        <dbl>     <dbl>      <dbl>
#> 1 year         15 169514394144. 11300959610.      213.  4.29e-102
#> 2 Residuals   171   9077385000.    53084123.       NA  NA

Before plotting, the results of the Tukey post-hoc test are passed to asymmetrise_stats() that prepares the data for geom_asymmat(). The resulting tibble is then plotted and styled in ‘ggplot2’.

asymmat_tib <- asymmetrise_stats(TukeyHSD(aov_res))
ggplot(asymmat_tib, aes(x = x, y = y)) +
  geom_asymmat(aes(
    fill_tl = estimate,
    fill_br = -log10(adj.p.value + 0.0000001)
  )) +
  scale_fill_tl_gradient2(low = "dodgerblue", high = "tomato") +
  scale_fill_br_distiller(type = "seq", palette = "Greens", direction = 1) +
  labs(
    title = "Median House Prices in Austin",
    fill_tl = "diff. in\nmean values",
    fill_br = "-log10( adj. p-value )"
  ) +
  theme(
    panel.background = element_rect(fill = "grey75"),
    panel.grid = element_blank()
  ) +
  scale_x_discrete(expand = c(0, 0)) +
  scale_y_discrete(expand = c(0, 0))


Thank yous

I would like to thank the team behind ‘ggplot2’ for creating a flexible and powerful package for the R community.

If you see any mistakes (including small typos) please open an issue and leave a quick statement. Do not worry about appearing annoying.

ggasym's People

Contributors

jhrcook avatar romainfrancois avatar simonpcouch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ggasym's Issues

`asymmetrize` example

Change the example so that a warning is not printed. The warning is good, but not really good to show in the showcase. Also show how the function observes groups from group_by – talk it up in the @description, too.

difficulty plotting with `correlation` package output

I have gone through the vignettes and adapted my dataframe accordingly but still can't seem to get this to work.

# setup
set.seed(123)
library(tidyverse)
library(ggasym)
library(parameters)
library(correlation)

# dataframe with cprrelations
(df <- as.data.frame(correlation(iris)))
#>     Parameter1   Parameter2          r     CI_low     CI_high         t  df
#> 1 Sepal.Length  Sepal.Width -0.1175698 -0.2726932  0.04351158 -1.440287 148
#> 2 Sepal.Length Petal.Length  0.8717538  0.8270363  0.90550805 21.646019 148
#> 3 Sepal.Length  Petal.Width  0.8179411  0.7568971  0.86483606 17.296454 148
#> 4  Sepal.Width Petal.Length -0.4284401 -0.5508771 -0.28794993 -5.768449 148
#> 5  Sepal.Width  Petal.Width -0.3661259 -0.4972130 -0.21869663 -4.786461 148
#> 6 Petal.Length  Petal.Width  0.9628654  0.9490525  0.97298532 43.387237 148
#>              p  Method n_Obs
#> 1 1.518983e-01 Pearson   150
#> 2 5.193337e-47 Pearson   150
#> 3 9.301992e-37 Pearson   150
#> 4 1.353994e-07 Pearson   150
#> 5 8.146457e-06 Pearson   150
#> 6 2.805002e-85 Pearson   150

# modifying it to the format expected by ggasym
(asymmat_tib <- 
  tidyr::unite(
  df,
  "contrast",
  Parameter1:Parameter2,
  remove = FALSE
) %>%
  asymmetrise_stats(.) %>%
  parameters::standardize_names(., "broom") %>%
  tibble::as_tibble())
#> # A tibble: 61 x 13
#>    contrast parameter1 parameter2 estimate conf.low conf.high statistic    df
#>    <chr>    <chr>      <chr>         <dbl>    <dbl>     <dbl>     <dbl> <int>
#>  1 Sepal.L… Sepal.Len… Sepal.Wid…   -0.118   -0.273    0.0435     -1.44   148
#>  2 Sepal.L… Sepal.Len… Petal.Len…    0.872    0.827    0.906      21.6    148
#>  3 Sepal.L… Sepal.Len… Petal.Wid…    0.818    0.757    0.865      17.3    148
#>  4 Sepal.W… Sepal.Wid… Petal.Len…   -0.428   -0.551   -0.288      -5.77   148
#>  5 Sepal.W… Sepal.Wid… Petal.Wid…   -0.366   -0.497   -0.219      -4.79   148
#>  6 Petal.L… Petal.Len… Petal.Wid…    0.963    0.949    0.973      43.4    148
#>  7 Sepal.L… Sepal.Len… Sepal.Wid…   -0.118   -0.273    0.0435     -1.44   148
#>  8 Sepal.L… Sepal.Len… Petal.Len…    0.872    0.827    0.906      21.6    148
#>  9 Sepal.L… Sepal.Len… Petal.Wid…    0.818    0.757    0.865      17.3    148
#> 10 Sepal.W… Sepal.Wid… Petal.Len…   -0.428   -0.551   -0.288      -5.77   148
#> # … with 51 more rows, and 5 more variables: p.value <dbl>, method <chr>,
#> #   n.obs <int>, x <chr>, y <chr>

# plot
ggplot(asymmat_tib, aes(x = x, y = y)) +
  geom_asymmat(aes(fill_tl = estimate, fill_br = -log(p.value)))

Created on 2020-12-22 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.3 (2020-10-10)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2020-12-22                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.0.2)
#>  backports     1.2.1   2020-12-09 [1] CRAN (R 4.0.3)
#>  bayestestR    0.8.0   2020-12-05 [1] CRAN (R 4.0.3)
#>  broom         0.7.3   2020-12-16 [1] CRAN (R 4.0.3)
#>  callr         3.5.1   2020-10-13 [1] CRAN (R 4.0.2)
#>  cellranger    1.1.0   2016-07-27 [1] CRAN (R 4.0.2)
#>  cli           2.2.0   2020-11-20 [1] CRAN (R 4.0.3)
#>  colorspace    2.0-0   2020-11-11 [1] CRAN (R 4.0.2)
#>  correlation * 0.5.0   2020-12-02 [1] CRAN (R 4.0.3)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 4.0.2)
#>  curl          4.3     2019-12-02 [1] CRAN (R 4.0.1)
#>  DBI           1.1.0   2019-12-15 [1] CRAN (R 4.0.2)
#>  dbplyr        2.0.0   2020-11-03 [1] CRAN (R 4.0.2)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 4.0.2)
#>  devtools      2.3.2   2020-09-18 [1] CRAN (R 4.0.2)
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.0.2)
#>  dplyr       * 1.0.2   2020-08-18 [1] CRAN (R 4.0.2)
#>  effectsize    0.4.1   2020-12-07 [1] CRAN (R 4.0.3)
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.2)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.0.1)
#>  fansi         0.4.1   2020-01-08 [1] CRAN (R 4.0.2)
#>  farver        2.0.3   2020-01-16 [1] CRAN (R 4.0.2)
#>  forcats     * 0.5.0   2020-03-01 [1] CRAN (R 4.0.2)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
#>  generics      0.1.0   2020-10-31 [1] CRAN (R 4.0.2)
#>  ggasym      * 0.1.5   2020-07-15 [1] CRAN (R 4.0.2)
#>  ggplot2     * 3.3.2   2020-06-19 [1] CRAN (R 4.0.2)
#>  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 4.0.2)
#>  haven         2.3.1   2020-06-01 [1] CRAN (R 4.0.2)
#>  highr         0.8     2019-03-20 [1] CRAN (R 4.0.2)
#>  hms           0.5.3   2020-01-08 [1] CRAN (R 4.0.2)
#>  htmltools     0.5.0   2020-06-16 [1] CRAN (R 4.0.2)
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.0.2)
#>  insight       0.11.1  2020-12-08 [1] CRAN (R 4.0.3)
#>  jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.0.3)
#>  knitr         1.30    2020-09-22 [1] CRAN (R 4.0.2)
#>  lifecycle     0.2.0   2020-03-06 [1] CRAN (R 4.0.2)
#>  lubridate     1.7.9.2 2020-11-13 [1] CRAN (R 4.0.3)
#>  magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.0.3)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 4.0.2)
#>  mime          0.9     2020-02-04 [1] CRAN (R 4.0.2)
#>  modelr        0.1.8   2020-05-19 [1] CRAN (R 4.0.2)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.0.2)
#>  parameters  * 0.10.1  2020-12-08 [1] CRAN (R 4.0.3)
#>  pillar        1.4.7   2020-11-20 [1] CRAN (R 4.0.3)
#>  pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.0.3)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.0.2)
#>  pkgload       1.1.0   2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.0.2)
#>  processx      3.4.5   2020-11-30 [1] CRAN (R 4.0.3)
#>  ps            1.5.0   2020-12-05 [1] CRAN (R 4.0.3)
#>  purrr       * 0.3.4   2020-04-17 [1] CRAN (R 4.0.2)
#>  R6            2.5.0   2020-10-28 [1] CRAN (R 4.0.2)
#>  Rcpp          1.0.5   2020-07-06 [1] CRAN (R 4.0.2)
#>  readr       * 1.4.0   2020-10-05 [1] CRAN (R 4.0.2)
#>  readxl        1.3.1   2019-03-13 [1] CRAN (R 4.0.2)
#>  remotes       2.2.0   2020-07-21 [1] CRAN (R 4.0.2)
#>  reprex        0.3.0   2019-05-16 [1] CRAN (R 4.0.2)
#>  rlang         0.4.9   2020-11-26 [1] CRAN (R 4.0.3)
#>  rmarkdown     2.6     2020-12-14 [1] CRAN (R 4.0.3)
#>  rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.0.3)
#>  rvest         0.3.6   2020-07-25 [1] CRAN (R 4.0.2)
#>  scales        1.1.1   2020-05-11 [1] CRAN (R 4.0.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi       1.5.3   2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr     * 1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat      3.0.1   2020-12-17 [1] CRAN (R 4.0.3)
#>  tibble      * 3.0.4   2020-10-12 [1] CRAN (R 4.0.2)
#>  tidyr       * 1.1.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  tidyselect    1.1.0   2020-05-11 [1] CRAN (R 4.0.2)
#>  tidyverse   * 1.3.0   2019-11-21 [1] CRAN (R 4.0.2)
#>  usethis       2.0.0   2020-12-10 [1] CRAN (R 4.0.3)
#>  utf8          1.1.4   2018-05-24 [1] CRAN (R 4.0.2)
#>  vctrs         0.3.6   2020-12-17 [1] CRAN (R 4.0.3)
#>  withr         2.3.0   2020-09-22 [1] CRAN (R 4.0.2)
#>  xfun          0.19    2020-10-30 [1] CRAN (R 4.0.2)
#>  xml2          1.3.2   2020-04-23 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
#> 
#> [1] /Users/patil/Library/R/4.0/library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

CRAN Check Failure for Upcoming broom Release

Hi there! The broom dev team just ran reverse dependency checks on the upcoming broom 0.7.0 release and found new errors/test failures for the CRAN version of this package. I've pasted the results below.

  • checking tests ...
     ERROR
    Running the tests in ‘tests/testthat.R’ failed.
    Last 13 lines of output:
      > 
      > test_check("ggasym")
      Error : No tidy method for objects of class character
      [31m──[39m [31m1. Error: stats asymmetrization works (@test-asymmetrise_stats.R#13) [39m [31m───────[39m
      Could not handle input data; try turning into a tibble using the broom package
      [1mBacktrace:[22m
      [90m 1. [39mtestthat::expect_warning(prepare_data(grps))
      [90m 6. [39mggasym::prepare_data(grps)
      
      ══ testthat results  ═══════════════════════════════════════════════════════════
      [ OK: 260 | SKIPPED: 0 | WARNINGS: 1 | FAILED: 1 ]
      1. Error: stats asymmetrization works (@test-asymmetrise_stats.R#13) 
      
      Error: testthat unit tests failed
      Execution halted
    

I believe these result from the following line in test-asymmetrise_stats:

expect_warning(prepare_data(grps))

broom now errors when given input data for which there are no tidiers.

We hope to submit this new version of the package to CRAN in the coming weeks. If you encounter any problems fixing these issues, please feel free to reach out!🙂

Failure with dev scales

The development version of scales now uses farver to perform colour interpolation. This has result in a few non-perceptual changes to changes, and it looks like you're testing for exact equality:

 Failure: scale_fill_tl/br/diag_gradient2 values populate properly (@test-scale_continuous_asym.R#185)
  g3_build$data[[3]]$fill_diag not equal to `diag_cols`.
  2/6 mismatches
  x[1]: "#E40081"
  y[1]: "#E30081"
  
  x[3]: "#E40081"
  y[3]: "#E30081"

Would you mind relaxing the test so I can get scales to CRAN in the next week or so?

Failure with upcoming ggplot2 release

We have detected the following issue with the next ggplot2 release

ggasym

Run cloud_details(, "ggasym") for more info

Newly broken

  • checking tests ... ERROR
      Running ‘spelling.R’
      Running ‘testthat.R’
    Running the tests in ‘tests/testthat.R’ failed.
    Complete output:
      > library(testthat)
      > library(ggasym)
      > 
      > test_check("ggasym")
      ── 1. Failure: geom_asymmat works (@test-geom_asymmat.R#48)  ───────────────────
      `ggplot_build(g_asymmat)` produced warnings.
      
      ══ testthat results  ═══════════════════════════════════════════════════════════
      [ OK: 266 | SKIPPED: 0 | WARNINGS: 36 | FAILED: 1 ]
      1. Failure: geom_asymmat works (@test-geom_asymmat.R#48) 
      
      Error: testthat unit tests failed
      Execution halted
    

Looking into it, the issue is in this line

if (class(.x_data) == "factor" | class(.y_data) == "factor") {

where you check for factor inheritance by comparing the class attribute with "factor". As the class attribute may be longer than one (and in the new release is for discrete mappings), you'll get the warning the condition has length > 1 and only the first element will be used. To fix this, change the class check to use inherit():

if (inherit(.x_data, "factor") | inherit(.y_data, "inherit")) {
...

which is the correct way to check for class inheritance.

We will submit ggplot2 v3.3.1 in two weeks, so please submit a fix before then — you are welcome to reach out with any questions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.