From d3524c4d6d05c5d39c92cdb8306bbecaf9728afd Mon Sep 17 00:00:00 2001 From: andrie Date: Sat, 30 Sep 2023 09:36:33 +0000 Subject: [PATCH] Fix deprecations and warnings in ggplot --- .Rbuildignore | 4 ++ .gitignore | 2 + DESCRIPTION | 4 +- NEWS => NEWS.md | 63 +++++++++++++---------------- R/ggdendrogram.R | 4 +- README.Rmd | 6 +-- README.md | 32 ++++++++------- inst/WORDLIST | 12 ++++-- inst/examples/example_dendro_tree.R | 2 +- man/dendro_data.tree.Rd | 2 +- vignettes/ggdendro.Rmd | 12 +++--- 11 files changed, 76 insertions(+), 67 deletions(-) rename NEWS => NEWS.md (73%) diff --git a/.Rbuildignore b/.Rbuildignore index 94747a0..54ceb9f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,7 @@ README.md ^cran-comments\.md$ ^CRAN-RELEASE$ ^codecov\.yml$ +^revdep$ +^CRAN-SUBMISSION$ +^doc$ +^Meta$ diff --git a/.gitignore b/.gitignore index 0d7f03b..130a84f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ .Ruserdata docs inst/doc +/doc/ +/Meta/ diff --git a/DESCRIPTION b/DESCRIPTION index 01b9fd4..1e4ede8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: ggdendro -Version: 0.1.23 +Version: 0.1.23.9000 Title: Create Dendrograms and Tree Diagrams Using 'ggplot2' Description: This is a set of tools for dendrograms and tree plots using 'ggplot2'. The 'ggplot2' philosophy is to @@ -32,7 +32,7 @@ Suggests: rmarkdown, covr VignetteBuilder: knitr -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.3 Language: en-US Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/NEWS b/NEWS.md similarity index 73% rename from NEWS rename to NEWS.md index f9b136c..c87372b 100644 --- a/NEWS +++ b/NEWS.md @@ -1,17 +1,19 @@ -ggdendro 0.1.23 (Release date: 2022-02-15) -=============== +# ggdendro 0.1.23.9000 + +- Fix deprecated ggplot aes usage + + +# ggdendro 0.1.23 * No functional changes. Minor changes only to comply with CRAN policy. -ggdendro 0.1.22 (Release date: 2020-09-13) -=============== +# ggdendro 0.1.22 * No functional changes * Update tests to conform with `testthat_3.0.0` -ggdendro 0.1.21 (Release date: 2020-08-08) -=============== +# ggdendro 0.1.21 Bug fixes: @@ -24,18 +26,16 @@ Other changes * Added spellcheck and fixed spelling mistakes -ggdendro 0.1-20 (Release date: 2016-04-27) -=============== +# ggdendro 0.1-20 Enhancements: * Don't open plot device during calculation of segment data #25 -ggdendro 0.1-19 (Release date: 2016-04-27) -=============== +# ggdendro 0.1-19 -Bug fix release +Bug fix release. Functional changes: @@ -48,8 +48,7 @@ Bug fixes: * Fixed issue #22: Margin not working for `dendro_data.rpart` -ggdendro 0.1-16 (Release date: 2016-09-06) -=============== +# ggdendro 0.1-16 New functionality: @@ -59,20 +58,19 @@ Fixes: - Many small changes and improvements to documentation -ggdendro 0.1-15 (Release date: 29/09/2014) -=============== +# ggdendro 0.1-15 New functionality: - None Changes: + - Some bug fixes - Unit tests now run during R CMD check - Modified vignette to use knitr instead of SWeave -ggdendro 0.1-14 (Release date: 2013-09-03) -=============== +# ggdendro 0.1-14 New functionality * Added support for rpart @@ -84,8 +82,7 @@ Changes: -ggdendro 0.1-12 (Release date: 2013-01-27) -=============== +# ggdendro 0.1-12 New functionality * None @@ -94,8 +91,7 @@ Changes: * ggdendro now imports MASS, tree and ggplot2 (rather than suggests) * Added Brian D. Ripley as author (original author of package tree) -ggdendro 0.1-09 (Release date: 2012-12-25) -=============== +# ggdendro 0.1-09 New functionality * None @@ -104,28 +100,29 @@ Changes: * Removed support for rpart * Changed Licence from GPL (>=2) to GPL-2|GPL-3 to conform with rtree license conditions -ggdendro 0.1-07 (Release date: 2012-08-30) -=============== +# ggdendro 0.1-07 + +New functionality: -New functionality * None Changes: + * Modified code to conform to `ggplot2` v0.9.2 -ggdendro 0.1-04 (Release date: 2012-02-02) -=============== +# ggdendro 0.1-04 + +New functionality: -New functionality * None * Modified examples to conform to ggplot2 v0.9 -ggdendro 0.1-02 (Release date: 19/10/2011) -=============== +# ggdendro 0.1-02 + +New functionality: -New functionality * Added support for classification trees using `package:rpart` Fixed bugs: @@ -135,15 +132,13 @@ Changes in API * Fixed inconsistencies in the names of the `data.frame` segments. The names are now always `x`, `y`, `xend` and `yend` -ggdendro 0.0-7 (Release date: 2011-08-12) -============== +# ggdendro 0.0-7 New functionality * Included the `ggdendrogram` function that conveniently creates a `ggplot` dendrogram in a single line of code. * Created `theme_dendro`, an almost blank theme -ggdendro 0.0 -============ +# ggdendro 0.0 Experimental release of package. diff --git a/R/ggdendrogram.R b/R/ggdendrogram.R index 2751cad..218cf33 100644 --- a/R/ggdendrogram.R +++ b/R/ggdendrogram.R @@ -62,13 +62,13 @@ ggdendrogram <- function(data, if (segments && !is.null(data$segments)) { p <- p + geom_segment( data = segment(data), - aes_string(x = "x", y = "y", xend = "xend", yend = "yend") + aes(x = .data[["x"]], y = .data[["y"]], xend = .data[["xend"]], yend = .data[["yend"]]) ) } if (leaf_labels && !is.null(data$leaf_labels)) { p <- p + geom_text( data = leaf_label(data), - aes_string(x = "x", y = "y", label = "label"), hjust = hjust, angle = angle, ... + aes(x = .data[["x"]], y = .data[["y"]], label = .data[["label"]]), hjust = hjust, angle = angle, ... ) } if (labels) { diff --git a/README.Rmd b/README.Rmd index 47db6fc..3fe889c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,9 +19,9 @@ Provides functions for creating dendrograms and tree plots using `ggplot2`. -[![R-CMD-check](https://github.com/andrie/ggdendro/workflows/R-CMD-check/badge.svg)](https://github.com/andrie/ggdendro/actions) -[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#inactive) -[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggdendro)](http://cran.r-project.org/package=ggdendro) +[![Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive) +[![CRAN status](https://www.r-pkg.org/badges/version/ggdendro)](https://CRAN.R-project.org/package=ggdendro) +[![R-CMD-check](https://github.com/andrie/ggdendro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrie/ggdendro/actions/workflows/R-CMD-check.yaml) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggdendro)](http://www.r-pkg.org/pkg/ggdendro) [![Codecov test coverage](https://codecov.io/gh/andrie/ggdendro/branch/main/graph/badge.svg)](https://app.codecov.io/gh/andrie/ggdendro?branch=main) diff --git a/README.md b/README.md index be36b08..b4614dd 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,13 @@ Provides functions for creating dendrograms and tree plots using -[![R-CMD-check](https://github.com/andrie/ggdendro/workflows/R-CMD-check/badge.svg)](https://github.com/andrie/ggdendro/actions) -[![Project Status: Active - The project has reached a stable, usable -state and is being actively -developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#inactive) -[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggdendro)](http://cran.r-project.org/package=ggdendro) +[![Project Status: Inactive – The project has reached a stable, usable +state but is no longer being actively developed; support/maintenance +will be provided as time +allows.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive) +[![CRAN +status](https://www.r-pkg.org/badges/version/ggdendro)](https://CRAN.R-project.org/package=ggdendro) +[![R-CMD-check](https://github.com/andrie/ggdendro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andrie/ggdendro/actions/workflows/R-CMD-check.yaml) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggdendro)](http://www.r-pkg.org/pkg/ggdendro) [![Codecov test @@ -22,23 +24,23 @@ coverage](https://codecov.io/gh/andrie/ggdendro/branch/main/graph/badge.svg)](ht The `ggdendro` package offers a generic function to extract data and text from the various clustering models: -- `dendro_data()` extracts cluster information from the model object, - e.g. cluster allocation, line segment data or label data. +- `dendro_data()` extracts cluster information from the model object, + e.g. cluster allocation, line segment data or label data. The `dendro_data` object has methods for the following classes: -- `tree` -- `hclust` -- `dendrogram` -- `rpart` +- `tree` +- `hclust` +- `dendrogram` +- `rpart` These methods create an object of class `dendro`, which is essentially a list of data frames. To extract the relevant data frames from the list, use the three accessor functions: -- `segment()` for the line segment data -- `label()` for the text for each end segment -- `leaf_label()` for the leaf labels of a tree diagram +- `segment()` for the line segment data +- `label()` for the text for each end segment +- `leaf_label()` for the leaf labels of a tree diagram The results of these functions can then be passed to `ggplot()` for plotting. @@ -65,6 +67,7 @@ ggplot() + ``` r + ### demonstrate plotting directly from object class hclust ggdendrogram(hc) ``` @@ -78,6 +81,7 @@ ggdendrogram(hc, rotate = TRUE) ``` r + ### demonstrate converting hclust to dendro using dendro_data first hcdata <- dendro_data(hc) ggdendrogram(hcdata, rotate = TRUE) + diff --git a/inst/WORDLIST b/inst/WORDLIST index 518822a..b4068ad 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,19 +1,25 @@ CMD +Codecov +Licence RStudio +SWeave Vries agnes arg args -cran +behaviour de -dendextend dendro diana +ggdendrogram ggplot hclust -https +knitr minbranch minlength nleaves +pkgdown rpart +rtree +tidyverse treeco diff --git a/inst/examples/example_dendro_tree.R b/inst/examples/example_dendro_tree.R index bba76fe..2f2c578 100644 --- a/inst/examples/example_dendro_tree.R +++ b/inst/examples/example_dendro_tree.R @@ -8,7 +8,7 @@ if (require(tree)) { data = cpus) tree_data <- dendro_data(cpus.ltr) ggplot(segment(tree_data)) + - geom_segment(aes(x = x, y = y, xend = xend, yend = yend, size = n), + geom_segment(aes(x = x, y = y, xend = xend, yend = yend, linewidth = n), colour = "lightblue" ) + scale_size("n") + diff --git a/man/dendro_data.tree.Rd b/man/dendro_data.tree.Rd index 881ab5e..5b69223 100644 --- a/man/dendro_data.tree.Rd +++ b/man/dendro_data.tree.Rd @@ -36,7 +36,7 @@ if (require(tree)) { data = cpus) tree_data <- dendro_data(cpus.ltr) ggplot(segment(tree_data)) + - geom_segment(aes(x = x, y = y, xend = xend, yend = yend, size = n), + geom_segment(aes(x = x, y = y, xend = xend, yend = yend, linewidth = n), colour = "lightblue" ) + scale_size("n") + diff --git a/vignettes/ggdendro.Rmd b/vignettes/ggdendro.Rmd index 74f73bc..fedf378 100644 --- a/vignettes/ggdendro.Rmd +++ b/vignettes/ggdendro.Rmd @@ -1,8 +1,8 @@ --- -title: "Introduction to ggdendro" +title: "Using 'ggdendro' to plot dendrograms" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Introduction to ggdendro} + %\VignetteIndexEntry{Using 'ggdendro' to plot dendrograms} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -15,8 +15,6 @@ knitr::opts_chunk$set( ``` -# Using the `ggdendro` package to plot dendrograms - The `ggdendro` package makes it easy to extract dendrogram and tree diagrams into a list of data frames. You can then use this list to recreate these types of plots using the `ggplot2` package. ## Introduction @@ -44,7 +42,7 @@ library(ggplot2) library(ggdendro) ``` -## Using the `ggdendrogram()` wrapper +## Using the 'ggdendrogram()' wrapper The `ggdendro` package extracts the plot data from dendrogram objects. Sometimes it is useful to have fine-grained control over the plot. Other times it might be more convenient to have a simple wrapper around `ggplot()` to produce a dendrogram with a small amount of code. @@ -58,7 +56,7 @@ ggdendrogram(hc, rotate = FALSE, size = 2) The next section shows how to take full control over the data extraction and subsequent plotting. -## Extracting the dendrogram plot data using `dendro_data()` +## Extracting the dendrogram plot data using 'dendro_data()' The `hclust()` and `dendrogram()` functions in R makes it easy to plot the results of hierarchical cluster analysis and other dendrograms in R. However, it is hard to extract the data from this analysis to customize these plots, since the `plot()` functions for both these classes prints directly without the option of returning the plot data. @@ -144,7 +142,7 @@ if(require(rpart)){ ``` -## Twins diagrams: agnes and diana +## Twins diagrams: 'agnes' and 'diana' The `cluster` package allows you to draw `agnes` and `diana` diagrams.