Skip to content

Commit

Permalink
allowing tidy-select
Browse files Browse the repository at this point in the history
  • Loading branch information
larmarange committed Mar 26, 2024
1 parent 70ec4cd commit 2d5885e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
20 changes: 14 additions & 6 deletions R/gglikert.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#' `variable_labels` argument.
#'
#' @param data a data frame
#' @param include variables to include, accept [tidy-select][dplyr::select]
#' @param include variables to include, accepts [tidy-select][dplyr::select]
#' syntax
#' @param weights optional variable name of a weighting variable,
#' accept [tidy-select][dplyr::select] syntax
#' accepts [tidy-select][dplyr::select] syntax
#' @param y name of the variable to be plotted on `y` axis (relevant when
#' `.question` is mapped to "facets, see examples),
#' accept [tidy-select][dplyr::select] syntax
#' accepts [tidy-select][dplyr::select] syntax
#' @param variable_labels a named list or a named vector of custom variable
#' labels
#' @param sort should the factor defined by `factor_to_sort` be sorted according
Expand All @@ -34,7 +34,8 @@
#' to compute the proportion?
#' @param factor_to_sort name of the factor column to sort if `sort` is not
#' equal to `"none"`; by default the list of questions passed to `include`;
#' should be one factor column of the tibble returned by `gglikert_data()`
#' should be one factor column of the tibble returned by `gglikert_data()`;
#' accepts [tidy-select][dplyr::select] syntax
#' @param exclude_fill_values Vector of values that should not be displayed
#' (but still taken into account for computing proportions),
#' see [position_likert()]
Expand Down Expand Up @@ -185,7 +186,7 @@ gglikert <- function(data,
sort = sort,
sort_method = sort_method,
sort_prop_include_center = sort_prop_include_center,
factor_to_sort = factor_to_sort,
factor_to_sort = {{ factor_to_sort }},
exclude_fill_values = exclude_fill_values
)

Expand Down Expand Up @@ -375,6 +376,13 @@ gglikert_data <- function(data,
arg_name = "include"
)

factor_to_sort <- broom.helpers::.select_to_varnames(
select = {{ factor_to_sort }},
data = data,
arg_name = "factor_to_sort",
select_single = TRUE
)

weights_var <- broom.helpers::.select_to_varnames(
select = {{ weights }},
data = data,
Expand Down Expand Up @@ -593,7 +601,7 @@ gglikert_stacked <- function(data,
sort = sort,
sort_method = sort_method,
sort_prop_include_center = sort_prop_include_center,
factor_to_sort = factor_to_sort,
factor_to_sort = {{ factor_to_sort }},
exclude_fill_values = NULL
)

Expand Down
9 changes: 5 additions & 4 deletions man/gglikert.Rd

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

0 comments on commit 2d5885e

Please sign in to comment.