diff --git a/NAMESPACE b/NAMESPACE index e46af27..42290a2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,8 +3,8 @@ S3method(round_any,POSIXct) S3method(round_any,numeric) export("%>%") +export(PositionDiverging) export(PositionLikert) -export(PositionLikertCount) export(StatCross) export(StatProp) export(StatWeightedMean) @@ -26,8 +26,8 @@ export(label_number_abs) export(label_percent_abs) export(likert_pal) export(pal_extender) +export(position_diverging) export(position_likert) -export(position_likert_count) export(round_any) export(scale_colour_extended) export(scale_fill_extended) diff --git a/NEWS.md b/NEWS.md index 51a5409..98ae3d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # ggstats (development version) +**Minor breaking change** + +* `position_likert_count()` has been renamed as `position_diverging()` + **Improvements** * new scale `scale_fill_likert()` diff --git a/R/position_likert.R b/R/position_likert.R index f154463..8fbecdf 100644 --- a/R/position_likert.R +++ b/R/position_likert.R @@ -1,10 +1,11 @@ #' Stack objects on top of each another and center them around 0 #' -#' `position_likert()` stacks proportion bars on top of each other and +#' `position_diverging()` stacks bars on top of each other and #' center them around zero (the same number of categories are displayed on -#' each side). This type of presentation is commonly used to display -#' Likert-type scales. -#' `position_likert_count()` uses counts instead of proportions. +#' each side). +#' `position_likert()` uses proportions instead of counts. This type of +#' presentation is commonly used to display Likert-type scales. +#' #' #' It is recommended to use `position_likert()` with `stat_prop()` #' and its `complete` argument (see examples). @@ -50,7 +51,7 @@ #' #' ggplot(diamonds) + #' aes(y = clarity, fill = cut) + -#' geom_bar(position = "likert_count") + +#' geom_bar(position = "diverging") + #' scale_x_continuous(label = label_number_abs()) + #' scale_fill_likert() #' @@ -144,13 +145,13 @@ position_likert <- function(vjust = 1, #' @export #' @rdname position_likert -position_likert_count <- function(vjust = 1, - reverse = FALSE, - exclude_fill_values = NULL, - cutoff = NULL) { +position_diverging <- function(vjust = 1, + reverse = FALSE, + exclude_fill_values = NULL, + cutoff = NULL) { ggplot2::ggproto( NULL, - PositionLikertCount, + PositionDiverging, vjust = vjust, reverse = reverse, exclude_fill_values = exclude_fill_values, @@ -295,7 +296,7 @@ pos_likert <- function(df, #' @format NULL #' @usage NULL #' @export -PositionLikertCount <- ggproto("PositionLikertCount", PositionLikert, +PositionDiverging <- ggproto("PositionDiverging", PositionLikert, fill = FALSE ) diff --git a/man/position_likert.Rd b/man/position_likert.Rd index f210517..1512c81 100644 --- a/man/position_likert.Rd +++ b/man/position_likert.Rd @@ -3,9 +3,9 @@ \docType{data} \name{position_likert} \alias{position_likert} -\alias{position_likert_count} +\alias{position_diverging} \alias{PositionLikert} -\alias{PositionLikertCount} +\alias{PositionDiverging} \title{Stack objects on top of each another and center them around 0} \usage{ position_likert( @@ -15,7 +15,7 @@ position_likert( cutoff = NULL ) -position_likert_count( +position_diverging( vjust = 1, reverse = FALSE, exclude_fill_values = NULL, @@ -44,11 +44,11 @@ By default (\code{NULL}), it will be equal to the number of categories divided by 2, i.e. it will be centered.} } \description{ -\code{position_likert()} stacks proportion bars on top of each other and +\code{position_diverging()} stacks bars on top of each other and center them around zero (the same number of categories are displayed on -each side). This type of presentation is commonly used to display -Likert-type scales. -\code{position_likert_count()} uses counts instead of proportions. +each side). +\code{position_likert()} uses proportions instead of counts. This type of +presentation is commonly used to display Likert-type scales. } \details{ It is recommended to use \code{position_likert()} with \code{stat_prop()} @@ -77,7 +77,7 @@ ggplot(diamonds) + ggplot(diamonds) + aes(y = clarity, fill = cut) + - geom_bar(position = "likert_count") + + geom_bar(position = "diverging") + scale_x_continuous(label = label_number_abs()) + scale_fill_likert() diff --git a/tests/testthat/test-position_likert.R b/tests/testthat/test-position_likert.R index 69ec031..15608f4 100644 --- a/tests/testthat/test-position_likert.R +++ b/tests/testthat/test-position_likert.R @@ -21,17 +21,17 @@ test_that("position_likert()", { p <- ggplot(diamonds) + aes(y = clarity, fill = cut) + - geom_bar(position = "likert_count") + + geom_bar(position = "diverging") + scale_x_continuous(label = label_number_abs()) + scale_fill_brewer(palette = "PiYG") vdiffr::expect_doppelganger( - "position_likert_count() base", + "position_diverging() base", p ) vdiffr::expect_doppelganger( - "position_likert_count() facet", + "position_diverging() facet", p + facet_grid(~ price > 2500) )