Skip to content

Commit

Permalink
Fix deprecations and warnings in ggplot
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Sep 30, 2023
1 parent 60b6243 commit d3524c4
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 67 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ README.md
^cran-comments\.md$
^CRAN-RELEASE$
^codecov\.yml$
^revdep$
^CRAN-SUBMISSION$
^doc$
^Meta$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.Ruserdata
docs
inst/doc
/doc/
/Meta/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
63 changes: 29 additions & 34 deletions NEWS → NEWS.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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
Expand All @@ -84,8 +82,7 @@ Changes:



ggdendro 0.1-12 (Release date: 2013-01-27)
===============
# ggdendro 0.1-12

New functionality
* None
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions R/ggdendrogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Provides functions for creating dendrograms and tree plots using `ggplot2`.


<!-- badges: start -->
[![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)
<!-- badges: end -->
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Provides functions for creating dendrograms and tree plots using

<!-- badges: start -->

[![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
Expand All @@ -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.
Expand All @@ -65,6 +67,7 @@ ggplot() +
<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />

``` r

### demonstrate plotting directly from object class hclust
ggdendrogram(hc)
```
Expand All @@ -78,6 +81,7 @@ ggdendrogram(hc, rotate = TRUE)
<img src="man/figures/README-unnamed-chunk-2-3.png" width="100%" />

``` r

### demonstrate converting hclust to dendro using dendro_data first
hcdata <- dendro_data(hc)
ggdendrogram(hcdata, rotate = TRUE) +
Expand Down
12 changes: 9 additions & 3 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion inst/examples/example_dendro_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") +
Expand Down
2 changes: 1 addition & 1 deletion man/dendro_data.tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions vignettes/ggdendro.Rmd
Original file line number Diff line number Diff line change
@@ -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}
---
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit d3524c4

Please sign in to comment.