-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Harmonize API #373
base: main
Are you sure you want to change the base?
Harmonize API #373
Conversation
Looks good! Only conflict we have is that we have |
Can change for |
So we (roughly) have the pattern |
One potential consideration is that ggplot2 names these sorts or arguments/aesthetics like: https://github.com/tidyverse/ggplot2/blob/main/R/geom-boxplot.R We don't use |
I don't think we cover this case here in our coding style guidelines: https://easystats.github.io/easystats/articles/conventions.html |
What about the alphas? library(easystats)
easystats_args <- NULL
for (pkg in easystats::easystats_packages()) {
fns <- ls(paste0("package:", pkg))
rds_filepath <- file.path(find.package(pkg), "NAMESPACE")
all_fns <- tryCatch(
as.data.frame(read.table(rds_filepath)),
error = function(e){
NULL
}
)
if (!is.null(all_fns)) {
names(all_fns) <- "func"
all_fns <- data_filter(all_fns, startsWith(all_fns$func, "S3method("))
fn <- gsub("S3method\\((.*)\\)", "\\1", all_fns$func)
fn <- gsub(",", ".", fn, fixed = TRUE)
all_args <- NULL
for (i in fn) {
all_args <- c(all_args, formalArgs(getFromNamespace(i, pkg)))
}
easystats_args <- c(easystats_args, sort(unique(all_args)))
}
}
grep("alpha", sort(unique(easystats_args)), value = TRUE)
#> [1] "alpha" "dispersion_alpha" "dot_alpha" "line_alpha"
#> [5] "posteriors_alpha" "priors_alpha" "rope_alpha" "si_alpha" Created on 2024-11-20 with reprex v2.1.1 |
alpha should come first like other aesthetics |
(Those are all plotting parameters and not alpha as in significance right? I think we use "level" for the latter everywhere) |
Let's add that to ensure consistency going forward |
Yes, I think so. |
library(easystats)
easystats_args <- NULL
for (pkg in easystats::easystats_packages()) {
fns <- ls(paste0("package:", pkg))
rds_filepath <- file.path(find.package(pkg), "NAMESPACE")
# for some packages, read.table fails...
all_fns <- tryCatch(
as.data.frame(read.table(rds_filepath)),
error = function(e){
NULL
}
)
if (!is.null(all_fns)) {
names(all_fns) <- "func"
all_fns <- data_filter(all_fns, startsWith(all_fns$func, "S3method("))
fn <- gsub("S3method\\((.*)\\)", "\\1", all_fns$func)
fn <- gsub(",", ".", fn, fixed = TRUE)
all_args <- NULL
for (i in fn) {
fun_args <- formalArgs(getFromNamespace(i, pkg))
all_args <- rbind(
all_args,
data.frame(args = fun_args, fun = i, pkg = pkg)
)
}
easystats_args <- rbind(easystats_args, all_args)
}
}
easystats_args[grepl("alpha", easystats_args$args, fixed = TRUE), ] |> export_table()
#> args | fun | pkg
#> ----------------------------------------------------------
#> rope_alpha | plot.see_bayesfactor_parameters | see
#> rope_alpha | plot.see_bayesfactor_savagedickey | see
#> alpha | plot.see_check_normality | see
#> dot_alpha | plot.see_check_normality | see
#> dot_alpha | plot.see_check_outliers | see
#> alpha | plot.see_check_residuals | see
#> dot_alpha | plot.see_check_residuals | see
#> rope_alpha | plot.see_equivalence_test | see
#> rope_alpha | plot.see_equivalence_test_df | see
#> rope_alpha | plot.see_equivalence_test_lm | see
#> priors_alpha | plot.see_estimate_density | see
#> posteriors_alpha | plot.see_estimate_density | see
#> priors_alpha | plot.see_p_direction | see
#> line_alpha | plot.see_p_function | see
#> priors_alpha | plot.see_p_significance | see
#> posteriors_alpha | plot.see_parameters_brms_meta | see
#> rope_alpha | plot.see_parameters_brms_meta | see
#> dispersion_alpha | plot.see_parameters_distribution | see
#> posteriors_alpha | plot.see_parameters_simulate | see
#> line_alpha | plot.see_performance_pp_check | see
#> alpha | plot.see_performance_simres | see
#> dot_alpha | plot.see_performance_simres | see
#> priors_alpha | plot.see_point_estimate | see
#> rope_alpha | plot.see_rope | see
#> si_alpha | plot.see_si | see
#> line_alpha | print.see_performance_pp_check | see |
And we have all the sizes... library(easystats)
easystats_args <- NULL
for (pkg in easystats::easystats_packages()) {
fns <- ls(paste0("package:", pkg))
rds_filepath <- file.path(find.package(pkg), "NAMESPACE")
all_fns <- tryCatch(
as.data.frame(read.table(rds_filepath)),
error = function(e){
NULL
}
)
if (!is.null(all_fns)) {
names(all_fns) <- "func"
all_fns <- data_filter(all_fns, startsWith(all_fns$func, "S3method("))
fn <- gsub("S3method\\((.*)\\)", "\\1", all_fns$func)
fn <- gsub(",", ".", fn, fixed = TRUE)
all_args <- NULL
for (i in fn) {
fun_args <- formalArgs(getFromNamespace(i, pkg))
all_args <- rbind(
all_args,
data.frame(args = fun_args, fun = i, pkg = pkg)
)
}
easystats_args <- rbind(easystats_args, all_args)
}
}
easystats_args[grepl("size", easystats_args$args, fixed = TRUE), ] |>
data_filter(pkg %in% c("see", "parameters")) |>
export_table()
#> args | fun | pkg
#> ------------------------------------------------------------------
#> font_size | display.compare_parameters | parameters
#> font_size | display.parameters_brms_meta | parameters
#> font_size | display.parameters_model | parameters
#> font_size | display.parameters_simulate | parameters
#> font_size | print_html.compare_parameters | parameters
#> font_size | print_html.parameters_brms_meta | parameters
#> font_size | print_html.parameters_model | parameters
#> font_size | print_html.parameters_sem | parameters
#> font_size | print_html.parameters_simulate | parameters
#> size_point | plot.see_bayesfactor_parameters | see
#> size_point | plot.see_bayesfactor_savagedickey | see
#> size_line | plot.see_binned_residuals | see
#> size_point | plot.see_binned_residuals | see
#> size_title | plot.see_binned_residuals | see
#> size_axis_title | plot.see_binned_residuals | see
#> base_size | plot.see_binned_residuals | see
#> size_point | plot.see_check_collinearity | see
#> size_line | plot.see_check_collinearity | see
#> size_title | plot.see_check_collinearity | see
#> size_axis_title | plot.see_check_collinearity | see
#> base_size | plot.see_check_collinearity | see
#> size_point | plot.see_check_dag | see
#> size_text | plot.see_check_dag | see
#> size_point | plot.see_check_distribution | see
#> size_point | plot.see_check_distribution_numeric | see
#> size_point | plot.see_check_heteroscedasticity | see
#> size_line | plot.see_check_heteroscedasticity | see
#> size_title | plot.see_check_heteroscedasticity | see
#> size_axis_title | plot.see_check_heteroscedasticity | see
#> base_size | plot.see_check_heteroscedasticity | see
#> size_line | plot.see_check_normality | see
#> size_point | plot.see_check_normality | see
#> size_title | plot.see_check_normality | see
#> size_axis_title | plot.see_check_normality | see
#> base_size | plot.see_check_normality | see
#> size_text | plot.see_check_outliers | see
#> size_line | plot.see_check_outliers | see
#> size_title | plot.see_check_outliers | see
#> size_axis_title | plot.see_check_outliers | see
#> base_size | plot.see_check_outliers | see
#> size_line | plot.see_check_overdisp | see
#> size_title | plot.see_check_overdisp | see
#> size_axis_title | plot.see_check_overdisp | see
#> base_size | plot.see_check_overdisp | see
#> size_line | plot.see_check_residuals | see
#> size_point | plot.see_check_residuals | see
#> size_title | plot.see_check_residuals | see
#> size_axis_title | plot.see_check_residuals | see
#> base_size | plot.see_check_residuals | see
#> size_point | plot.see_compare_parameters | see
#> size_text | plot.see_compare_parameters | see
#> size_line | plot.see_compare_performance | see
#> size_point | plot.see_equivalence_test_lm | see
#> size_line | plot.see_estimate_density | see
#> size_point | plot.see_estimate_density | see
#> size_line | plot.see_estimate_density_df | see
#> size | plot.see_n_clusters | see
#> size | plot.see_n_factors | see
#> size_point | plot.see_p_function | see
#> size_line | plot.see_p_function | see
#> size_text | plot.see_p_function | see
#> size_point | plot.see_parameters_brms_meta | see
#> size_line | plot.see_parameters_brms_meta | see
#> size_text | plot.see_parameters_brms_meta | see
#> size_bar | plot.see_parameters_distribution | see
#> size_text | plot.see_parameters_efa | see
#> size | plot.see_parameters_efa | see
#> size_point | plot.see_parameters_model | see
#> size_text | plot.see_parameters_model | see
#> size_text | plot.see_parameters_pca | see
#> size | plot.see_parameters_pca | see
#> size_point | plot.see_parameters_sem | see
#> size_line | plot.see_parameters_simulate | see
#> size_line | plot.see_performance_pp_check | see
#> size_point | plot.see_performance_pp_check | see
#> size_bar | plot.see_performance_pp_check | see
#> size_axis_title | plot.see_performance_pp_check | see
#> size_title | plot.see_performance_pp_check | see
#> base_size | plot.see_performance_pp_check | see
#> size_line | plot.see_performance_simres | see
#> size_point | plot.see_performance_simres | see
#> size_title | plot.see_performance_simres | see
#> size_axis_title | plot.see_performance_simres | see
#> base_size | plot.see_performance_simres | see
#> size_point | plot.see_point_estimate | see
#> size_text | plot.see_point_estimate | see
#> size_line | print.see_performance_pp_check | see
#> size_point | print.see_performance_pp_check | see
#> size_bar | print.see_performance_pp_check | see
#> size_axis_title | print.see_performance_pp_check | see
#> size_title | print.see_performance_pp_check | see
#> base_size | print.see_performance_pp_check | see |
size_line we should change to linewidth since that's the correct ggplot2 argument now |
Let's leave font_size |
I think we should change the arguments in |
Yep absolutely. Are there other functions that also have plotting arguments? |
I don't think so. It's because check_model does only plotting, you don't need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of places where we say "color" to refer fill type variables. Should we switch to "fill_" for those? I'm leaning toward no, as we use one color argument to set both fill and color aesthetics in several places
#' @param dispersion_alpha Numeric value specifying the transparency level of dispersion ribbon. | ||
#' @param dispersion_color Character specifying the color of dispersion ribbon. | ||
#' @param alpha_dispersion Numeric value specifying the transparency level of dispersion ribbon. | ||
#' @param color_dispersion Character specifying the color of dispersion ribbon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be fill_dispersion
?
#' @param dispersion_style Character describing the style of dispersion area. | ||
#' `"ribbon"` for a ribbon, `"curve"` for a normal-curve. | ||
#' @param highlight A vector with names of categories in `x` that should be | ||
#' highlighted. | ||
#' @param highlight_color A vector of color values for highlighted categories. | ||
#' @param color_highlight A vector of color values for highlighted categories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be fill_highlight
?
@@ -12,7 +12,7 @@ | |||
#' If `TRUE`, confidence intervals computed using the Wilson method are shown. | |||
#' See Brown et al. (2001) for details. | |||
#' @param ci Confidence Interval (CI) level. Defaults to `0.95` (`95%`). | |||
#' @param fill_col Color to use for category columns (default: `"#87CEFA"`). | |||
#' @param color_fill Color to use for category columns (default: `"#87CEFA"`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be fill_bar
or just fill
?
cf. easystats/easystats#434
color_*
pattern