Skip to content

Commit

Permalink
position_likert_count() has been renamed as position_diverging()
Browse files Browse the repository at this point in the history
  • Loading branch information
larmarange committed Aug 20, 2024
1 parent a4eda38 commit b0ed0ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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()`
Expand Down
23 changes: 12 additions & 11 deletions R/position_likert.R
Original file line number Diff line number Diff line change
@@ -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).
Expand Down Expand Up @@ -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()
#'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -295,7 +296,7 @@ pos_likert <- function(df,
#' @format NULL
#' @usage NULL
#' @export
PositionLikertCount <- ggproto("PositionLikertCount", PositionLikert,
PositionDiverging <- ggproto("PositionDiverging", PositionLikert,
fill = FALSE
)

Expand Down
16 changes: 8 additions & 8 deletions man/position_likert.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat/test-position_likert.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down

0 comments on commit b0ed0ff

Please sign in to comment.