Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use lifecycle for arguments deprecation in ggpairs #494

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ importFrom(grid,upViewport)
importFrom(grid,viewport)
importFrom(gtable,gtable_filter)
importFrom(lifecycle,deprecate_soft)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(plyr,ddply)
importFrom(plyr,summarize)
Expand Down
1 change: 1 addition & 0 deletions R/GGally-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# roxygen namespace tags. Modify with care!
## usethis namespace: start
#' @importFrom lifecycle deprecate_soft
#' @importFrom lifecycle deprecated
## usethis namespace: end
NULL

Expand Down
65 changes: 33 additions & 32 deletions R/ggpairs.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,6 @@ fix_column_values <- function(
columns
}

warn_deprecated <- function(is_supplied, title) {
if (is_supplied) {
warning(paste(
"'", title, "' will be deprecated in future versions. Please remove it from your code",
sep = ""
))
}
}

stop_if_bad_mapping <- function(mapping) {
if (is.numeric(mapping)) {
stop(
Expand All @@ -146,18 +137,6 @@ stop_if_bad_mapping <- function(mapping) {
}
}

warn_if_args_exist <- function(args) {
if (length(args) > 0) {
argNames <- names(args)
warning(str_c(
"Extra arguments: ",
str_c(shQuote(argNames), collapse = ", "), " are being ignored.",
" If these are meant to be aesthetics, submit them using the",
" 'mapping' variable within ggpairs with ggplot2::aes or ggplot2::aes_string."
))
}
}

fix_axis_label_choice <- function(axisLabels, axisLabelChoices) {
if (length(axisLabels) > 1) {
axisLabels <- axisLabels[1]
Expand Down Expand Up @@ -234,7 +213,7 @@ stop_if_high_cardinality <- function(data, columns, threshold) {
#' @template ggmatrix-legend-param
#' @param cardinality_threshold maximum number of levels allowed in a character / factor column. Set this value to NULL to not check factor columns. Defaults to 15
#' @template ggmatrix-progress
#' @param legends deprecated
#' @param legends `r lifecycle::badge('deprecated')`
#' @param xProportions,yProportions Value to change how much area is given for each plot. Either \code{NULL} (default), numeric value matching respective length, \code{grid::\link[grid]{unit}} object with matching respective length or \code{"auto"} for automatic relative proportions based on the number of levels for categorical variables.
#' @export
#' @examples
Expand Down Expand Up @@ -456,8 +435,14 @@ ggduo <- function(
progress = NULL,
xProportions = NULL,
yProportions = NULL,
legends = stop("deprecated")) {
warn_deprecated(!missing(legends), "legends")
legends = deprecated()) {
if (lifecycle::is_present(legends)) {
lifecycle::deprecate_warn(
when = "2.2.2",
what = "ggduo(legends)",
details = "Ability to put legends in each plot will be dropped in next releases."
)
}

isSharedData <- inherits(data, "SharedData")
data_ <- fix_data(data)
Expand Down Expand Up @@ -623,8 +608,8 @@ ggduo <- function(
#' @param upper see Details
#' @param lower see Details
#' @param diag see Details
#' @param params deprecated. Please see \code{\link{wrap_fn_with_param_arg}}
#' @param ... deprecated. Please use \code{mapping}
#' @param params `r lifecycle::badge("deprecated")` see \code{\link{wrap_fn_with_param_arg}}
92amartins marked this conversation as resolved.
Show resolved Hide resolved
#' @param ... `r lifecycle::badge("deprecated")` use \code{mapping}
92amartins marked this conversation as resolved.
Show resolved Hide resolved
#' @param axisLabels either "show" to display axisLabels, "internal" for labels in the diagonal plots, or "none" for no axis labels
#' @param columnLabels label names to be displayed. Defaults to names of columns being used.
#' @param proportions Value to change how much area is given for each plot. Either \code{NULL} (default), numeric value matching respective length, \code{grid::\link[grid]{unit}} object with matching respective length or \code{"auto"} for automatic relative proportions based on the number of levels for categorical variables.
Expand All @@ -634,7 +619,7 @@ ggduo <- function(
#' @template ggmatrix-legend-param
#' @param cardinality_threshold maximum number of levels allowed in a character / factor column. Set this value to NULL to not check factor columns. Defaults to 15
#' @template ggmatrix-progress
#' @param legends deprecated
#' @param legends `r lifecycle::badge("deprecated")`
#' @keywords hplot
#' @import ggplot2
#' @references John W Emerson, Walton A Green, Barret Schloerke, Jason Crowley, Dianne Cook, Heike Hofmann, Hadley Wickham. The Generalized Pairs Plot. Journal of Computational and Graphical Statistics, vol. 22, no. 1, pp. 79-91, 2012.
Expand Down Expand Up @@ -768,7 +753,7 @@ ggpairs <- function(
upper = list(continuous = "cor", combo = "box_no_facet", discrete = "count", na = "na"),
lower = list(continuous = "points", combo = "facethist", discrete = "facetbar", na = "na"),
diag = list(continuous = "densityDiag", discrete = "barDiag", na = "naDiag"),
params = NULL,
params = deprecated(),
...,
xlab = NULL,
ylab = NULL,
Expand All @@ -781,10 +766,26 @@ ggpairs <- function(
cardinality_threshold = 15,
progress = NULL,
proportions = NULL,
legends = stop("deprecated")) {
warn_deprecated(!missing(legends), "legends")
warn_if_args_exist(list(...))
stop_if_params_exist(params)
legends = deprecated()) {
if (lifecycle::is_present(legends)) {
lifecycle::deprecate_warn(
when = "2.2.2",
what = "ggpairs(legends)",
details = "Ability to put legends in each plot will be dropped in next releases."
)
}
if (lifecycle::is_present(params)) {
lifecycle::deprecate_warn(
when = "2.2.2",
what = "ggpairs(params)"
)
}
has_dots <- rlang::check_dots_empty(error = function(cnd) {
TRUE
})
if (isTRUE(has_dots)) {
lifecycle::deprecate_soft(when = "2.2.2", what = "ggpais(...)")
}

isSharedData <- inherits(data, "SharedData")

Expand Down
22 changes: 21 additions & 1 deletion man/figures/lifecycle-archived.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion man/figures/lifecycle-defunct.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion man/figures/lifecycle-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion man/figures/lifecycle-experimental.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion man/figures/lifecycle-maturing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion man/figures/lifecycle-questioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading