diff --git a/NAMESPACE b/NAMESPACE index 0643ae0..7f81592 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,42 +1,12 @@ # Generated by roxygen2: do not edit by hand -S3method(add_coefs,clm) -S3method(add_coefs,default) -S3method(add_coefs,polr) -S3method(add_greek,clm) -S3method(add_greek,default) -S3method(add_greek,polr) -S3method(create_eq,clm) -S3method(create_eq,default) -S3method(create_eq,glm) -S3method(create_eq,polr) -S3method(create_l1,glmerMod) -S3method(create_l1,lmerMod) -S3method(create_term,default) -S3method(create_term,forecast_ARIMA) S3method(extract_eq,default) S3method(extract_eq,forecast_ARIMA) S3method(extract_eq,glmerMod) S3method(extract_eq,lmerMod) -S3method(extract_lhs,clm) -S3method(extract_lhs,glm) -S3method(extract_lhs,glmerMod) -S3method(extract_lhs,lm) -S3method(extract_lhs,lmerMod) -S3method(extract_lhs,polr) -S3method(extract_rhs,default) -S3method(extract_rhs,glmerMod) -S3method(extract_rhs,lmerMod) S3method(format,equation) S3method(knit_print,equation) -S3method(modify_lhs_for_link,clm) -S3method(modify_lhs_for_link,glm) -S3method(modify_lhs_for_link,polr) S3method(print,equation) -S3method(wrap_rhs,clm) -S3method(wrap_rhs,default) -S3method(wrap_rhs,glm) -S3method(wrap_rhs,polr) export(eqOutput) export(extract_eq) export(renderEq) diff --git a/NEWS.md b/NEWS.md index bedd314..4393da8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ # equatiomatic 0.3.3 * Vignette 'intro-equatiomatic' renamed 'equatiomatic' to enable a "Getting Started" entry in the pkgdown site. +* Documentation was cleaned up. In particular, methods for internal generics are + not exported any more. All methods for `extract_eq()` are now properly + documented in the `extract_eq()` help page. # equatiomatic 0.3.2 * New maintainer (Philippe Grosjean phgrosjean@sciviews.org). diff --git a/R/create_eq.R b/R/create_eq.R index 61565bc..3b375be 100644 --- a/R/create_eq.R +++ b/R/create_eq.R @@ -4,7 +4,6 @@ create_eq <- function(model, lhs, ...) { #' Create the full equation #' -#' @export #' @keywords internal #' #' @param lhs A character string of the left-hand side variable extracted with @@ -61,7 +60,6 @@ create_eq.default <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits list(lhs = list(lhs), rhs = list(rhs$final_terms)) } -#' @export #' @noRd #' @inheritParams extract_eq create_eq.glm <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits, @@ -102,7 +100,6 @@ create_eq.glm <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits, list(lhs = list(lhs), rhs = list(rhs$final_terms)) } -#' @export #' @noRd create_eq.polr <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits, fix_signs, intercept, greek, @@ -142,7 +139,6 @@ create_eq.polr <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits, list(lhs = lhs, rhs = rhs_final) } -#' @export #' @noRd create_eq.clm <- function(model, lhs, rhs, ital_vars, use_coefs, coef_digits, fix_signs, intercept, greek, @@ -309,7 +305,6 @@ create_term <- function(side, ...) { } #' @noRd -#' @export create_term.default <- function(side, ital_vars, swap_var_names, swap_subscript_names, var_colors, var_subscript_colors, ...) { @@ -403,7 +398,6 @@ check_math <- function(primary, subscripts) { #' #' @inheritParams extract_eq #' @noRd -#' @export create_term.forecast_ARIMA <- function(side, ital_vars, swap_var_names, swap_subscript_names, ...) { check_dots(...) @@ -636,7 +630,6 @@ add_coefs <- function(rhs, ...) { #' Add coefficient values to the equation #' -#' @export #' @keywords internal #' @noRd @@ -650,7 +643,6 @@ add_coefs.default <- function(rhs, term, coef_digits, ...) { ) } -#' @export #' @keywords internal #' @noRd @@ -664,7 +656,6 @@ add_coefs.polr <- function(rhs, term, coef_digits, ...) { ) } -#' @export #' @keywords internal #' @noRd @@ -714,7 +705,6 @@ add_greek <- function(rhs, ...) { #' Adds greek symbols to the equation #' -#' @export #' @keywords internal #' @noRd @@ -749,7 +739,6 @@ add_greek.default <- function(rhs, terms, greek = "beta", intercept = "alpha", ) } -#' @export #' @keywords internal #' @noRd @@ -777,7 +766,6 @@ add_greek.polr <- function(rhs, terms, greek, intercept, greek_colors, ) } -#' @export #' @keywords internal #' @noRd diff --git a/R/extract_eq.R b/R/extract_eq.R index cda3e3a..9ae6fca 100644 --- a/R/extract_eq.R +++ b/R/extract_eq.R @@ -1,10 +1,20 @@ -#' 'LaTeX' code for R models +# PhG: I am not a fan of stating all the possible arguments in the generic +# function like it is currently the case for extract_eq(). May be keep only the +# common and most used ones and allow for varying arguments with ... However, +# changing this could possibly break backward compatibility. So, I leave it as +# it is for now... but I had to homogenize for all methods, otherwise CRAN would +# reject the package! + +#' 'LaTeX' equation for R models #' -#' `r lifecycle::badge("maturing")` - -#' Extract the variable names from a model to produce a 'LaTeX' equation, which is -#' output to the screen. Supports any model supported by -#' [broom::tidy][broom::tidy]. +#' Extract the variable names from a model to produce a 'LaTeX' equation. +#' Supports any model where there is a [broom::tidy()] method. This is a generic +#' function with methods for lmerMod objects obtained with [lme4::lmer()], +#' glmerMod objects with [lme4::glmer()], forecast_ARIMA with +#' [forecast::Arima()] and default, with the later further covering most "base" +#' R models implemented in [broom::tidy()] like lm objects with [stats::lm()], +#' glm objects with [stats::glm()] or polr objects with [MASS::polr()]. The +#' default method also supports clm objects obtained with [ordinal::clm()]. #' #' @param model A fitted model #' @param intercept How should the intercept be displayed? Default is \code{"alpha"}, @@ -97,7 +107,12 @@ #' @export #' #' @return A character of class \dQuote{equation}. -#' +#' +#' @details +#' The different methods all use the same arguments, but not all arguments are +#' suitable to all models. Check here above to determine if a feature is +#' implemented for a given model. +#' #' @examples #' # Simple model #' mod1 <- lm(mpg ~ cyl + disp, mtcars) @@ -162,11 +177,12 @@ extract_eq <- function(model, intercept = "alpha", greek = "beta", operator_location = "end", align_env = "aligned", use_coefs = FALSE, coef_digits = 2, fix_signs = TRUE, font_size = NULL, - mean_separate, return_variances = FALSE, + mean_separate = NULL, return_variances = FALSE, se_subscripts = FALSE, ...) { UseMethod("extract_eq", model) } +# PhG: we do not want to repeat usage, so no @describeIn extract_eq default `extract_eq()` method #' Default function for extracting an equation from a model object #' #' @keywords internal @@ -183,7 +199,7 @@ extract_eq.default <- function(model, intercept = "alpha", greek = "beta", operator_location = "end", align_env = "aligned", use_coefs = FALSE, coef_digits = 2, fix_signs = TRUE, font_size = NULL, - mean_separate, return_variances = FALSE, + mean_separate = NULL, return_variances = FALSE, se_subscripts = FALSE, ...) { if (index_factors & use_coefs) { stop("Coefficient estimates cannot be returned when factors are indexed.") @@ -310,23 +326,28 @@ extract_eq.default <- function(model, intercept = "alpha", greek = "beta", # I haven't incorporated wrap yet either and we should think about if we want to # It might be better to have an alternative for matrix notation -#' Equation generator for lme4::lmer models +# PhG: we do not want to repeat usage, so no @describeIn extract_eq lmerMod `extract_eq()` method #' @export #' @noRd extract_eq.lmerMod <- function(model, intercept = "alpha", greek = "beta", greek_colors = NULL, subscript_colors = NULL, var_colors = NULL, var_subscript_colors = NULL, - raw_tex = FALSE, swap_var_names = NULL, - swap_subscript_names = NULL, + raw_tex = FALSE, + swap_var_names = NULL, swap_subscript_names = NULL, ital_vars = FALSE, label = NULL, index_factors = FALSE, show_distribution = FALSE, wrap = FALSE, terms_per_line = 4, - operator_location = "end", - align_env = "aligned", + operator_location = "end", align_env = "aligned", use_coefs = FALSE, coef_digits = 2, - fix_signs = TRUE, - font_size = NULL, mean_separate = NULL, - return_variances = FALSE, ...) { + fix_signs = TRUE, font_size = NULL, + mean_separate = NULL, return_variances = FALSE, + se_subscripts = FALSE, ...) { + if (isTRUE(se_subscripts)) { + warning("Standard errors are not supported for mixed effects models", + call. = FALSE + ) + } + if (!is.null(greek_colors)) { warning( paste0("Colorization of greek notation not currently ", @@ -385,11 +406,22 @@ extract_eq.lmerMod <- function(model, intercept = "alpha", greek = "beta", eq } +# PhG: we do not want to repeat usage, so no @describeIn extract_eq glmerMod `extract_eq()` method #' @export #' @noRd -extract_eq.glmerMod <- function(..., - greek_colors = NULL, - subscript_colors = NULL) { +extract_eq.glmerMod <- function(model, intercept = "alpha", greek = "beta", + greek_colors = NULL, subscript_colors = NULL, + var_colors = NULL, var_subscript_colors = NULL, + raw_tex = FALSE, + swap_var_names = NULL, swap_subscript_names = NULL, + ital_vars = FALSE, label = NULL, + index_factors = FALSE, show_distribution = FALSE, + wrap = FALSE, terms_per_line = 4, + operator_location = "end", align_env = "aligned", + use_coefs = FALSE, coef_digits = 2, + fix_signs = TRUE, font_size = NULL, + mean_separate = NULL, return_variances = FALSE, + se_subscripts = FALSE, ...) { if (!is.null(greek_colors)) { warning( paste0("Colorization of greek notation not currently ", @@ -400,10 +432,20 @@ extract_eq.glmerMod <- function(..., paste0("Colorization of subscripts not currently ", "implemented for merMod models")) } - extract_eq.lmerMod(...) + extract_eq.lmerMod(model, intercept = intercept, greek = greek, + greek_colors = greek_colors, subscript_colors = subscript_colors, + var_colors = var_colors, var_subscript_colors = var_subscript_colors, + raw_tex = raw_tex, swap_var_names = swap_var_names, + swap_subscript_names = swap_subscript_names, ital_vars = ital_vars, + label = label, index_factors = index_factors, + show_distribution = show_distribution, wrap = wrap, + terms_per_line = terms_per_line, operator_location = operator_location, + align_env = align_env, use_coefs = use_coefs, coef_digits = coef_digits, + fix_signs = fix_signs, font_size = font_size, mean_separate = mean_separate, + return_variances = return_variances, se_subscripts = se_subscripts, ...) } -#' Equation generator for forecast::Arima +# PhG: we do not want to repeat usage, so no @describeIn extract_eq forecast_ARIMA `extract_eq()` method #' @export #' @noRd extract_eq.forecast_ARIMA <- function(model, intercept = "alpha", greek = "beta", @@ -417,8 +459,15 @@ extract_eq.forecast_ARIMA <- function(model, intercept = "alpha", greek = "beta" operator_location = "end", align_env = "aligned", use_coefs = FALSE, coef_digits = 2, fix_signs = TRUE, font_size = NULL, - mean_separate, return_variances = FALSE, ...) { + mean_separate = NULL, return_variances = FALSE, + se_subscripts = FALSE, ...) { + if (isTRUE(se_subscripts)) { + warning("Standard errors are not supported for mixed effects models", + call. = FALSE + ) + } + # Determine if we are working on Regression w/ Arima Errors regression <- helper_arima_is_regression(model) @@ -522,7 +571,8 @@ extract_eq.forecast_ARIMA <- function(model, intercept = "alpha", greek = "beta" #' @param coef character vector of model coefficients (from output of the function create_eq) #' @param model a fitted model #' -#' @return a character vector adding the errors beneath each term +#' @return a character vector adding the errors beneath each term +#' @noRd add_se <- function(coef, model) { errors <- summary(model)$coefficients[,"Std. Error"] errors <- as.character(round(errors, 3)) @@ -542,13 +592,14 @@ add_se <- function(coef, model) { #' #' @param equation list that contains the equation #' -#' @return a list containing the equation with fixed signs +#' @return a list containing the equation with fixed signs +#' @noRd fix_coef_signs_se <- function(equation) { components <- strsplit(equation, " + ", fixed = TRUE) components <- unlist(components) terms <- components[2:length(components)] negative <- ifelse(grepl(terms, pattern = "-"), " - ", " + ") terms <- lapply(X = terms, FUN = gsub, pattern = "-", replacement = "") - terms <- paste0(negative, terms, collapse="") + terms <- paste0(negative, terms, collapse = "") list(paste(components[1], terms)) } diff --git a/R/extract_lhs.R b/R/extract_lhs.R index b0a9076..b730cc7 100644 --- a/R/extract_lhs.R +++ b/R/extract_lhs.R @@ -14,7 +14,6 @@ extract_lhs <- function(model, ...) { #' #' Extract a string of the outcome/dependent/y variable of a model #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -48,7 +47,6 @@ extract_lhs.lm <- function(model, ital_vars, show_distribution, use_coefs, #' #' Extract a string of the outcome/dependent/y variable of a model #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -81,7 +79,6 @@ extract_lhs.lmerMod <- function(model, ital_vars, use_coefs, swap_var_names, #' #' Extract a string of the outcome/dependent/y variable of a model #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -97,7 +94,6 @@ extract_lhs.glmerMod <- function(model, ital_vars, use_coefs, ...) { #' Extract a string of the outcome/dependent/y variable with the appropriate #' link function. #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -298,7 +294,6 @@ extract_lhs2_binomial <- function(model, ital_vars, use_coefs, swap_var_names, #' Extract a string of the outcome/dependent/y variable with the appropriate #' link function. #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -333,7 +328,6 @@ extract_lhs.polr <- function(model, ital_vars, ...) { #' Extract a string of the outcome/dependent/y variable with the appropriate #' link function. #' -#' @export #' @keywords internal #' #' @inheritParams extract_eq @@ -370,7 +364,6 @@ modify_lhs_for_link <- function(model, ...) { UseMethod("modify_lhs_for_link", model) } -#' @export #' @keywords internal #' @noRd modify_lhs_for_link.glm <- function(model, lhs, ...) { @@ -388,7 +381,6 @@ modify_lhs_for_link.glm <- function(model, lhs, ...) { gsub("y", lhs, filtered_link_formula, fixed = TRUE) } -#' @export #' @keywords internal #' @noRd modify_lhs_for_link.polr <- function(model, lhs, ...) { @@ -399,7 +391,6 @@ modify_lhs_for_link.polr <- function(model, lhs, ...) { gsub("y", lhs, filtered_link_formula, fixed = TRUE) } -#' @export #' @keywords internal #' @noRd modify_lhs_for_link.clm <- function(model, lhs, ...) { diff --git a/R/extract_rhs.R b/R/extract_rhs.R index 2e5985f..e46dd45 100644 --- a/R/extract_rhs.R +++ b/R/extract_rhs.R @@ -23,7 +23,6 @@ extract_rhs <- function(model, ...) { #' like subscripts are nested inside each list element. List elements with two #' or more terms are interactions. #' @noRd -#' @export #' @examples #' \dontrun{ #' library(palmerpenguins) @@ -113,7 +112,6 @@ extract_rhs.default <- function(model, index_factors, ...) { } #' @noRd -#' @export extract_rhs.lmerMod <- function(model, return_variances, ...) { check_dots(...) @@ -227,7 +225,6 @@ extract_rhs.lmerMod <- function(model, return_variances, ...) { } #' @noRd -#' @export extract_rhs.glmerMod <- function(model, ...) { extract_rhs.lmerMod(model, ...) } @@ -672,14 +669,12 @@ wrap_rhs <- function(model, tex, ...) { UseMethod("wrap_rhs", model) } -#' @export #' @keywords internal #' @noRd wrap_rhs.default <- function(model, tex, ...) { return(tex) } -#' @export #' @keywords internal #' @noRd wrap_rhs.glm <- function(model, tex, ...) { @@ -692,7 +687,6 @@ wrap_rhs.glm <- function(model, tex, ...) { return(rhs) } -#' @export #' @keywords internal #' @noRd wrap_rhs.polr <- function(model, tex, ...) { @@ -705,7 +699,6 @@ wrap_rhs.polr <- function(model, tex, ...) { return(rhs) } -#' @export #' @keywords internal #' @noRd wrap_rhs.clm <- function(model, tex, ...) { diff --git a/R/merMod.R b/R/merMod.R index 2808bac..43a7554 100644 --- a/R/merMod.R +++ b/R/merMod.R @@ -755,7 +755,6 @@ create_l1 <- function(model, ...) { #' names not be wrapped in the \code{\\operatorname{}} command? #' @param sigma The error term. Defaults to "\\sigma^2". #' @keywords internal -#' @export #' @noRd #' @examples \dontrun{ #' library(lme4) @@ -789,8 +788,6 @@ create_l1.lmerMod <- function(model, mean_separate, } } -#' @export -#' @noRd create_l1.glmerMod <- function(model, mean_separate, ital_vars, wrap, terms_per_line, use_coefs, coef_digits, fix_signs, diff --git a/R/print.R b/R/print.R index ab08895..0a8378a 100644 --- a/R/print.R +++ b/R/print.R @@ -1,33 +1,37 @@ #' Print 'LaTeX' equations #' -#' lifecycle::badge("stable")` -#' #' Print 'LaTeX' equations built with \code{\link{extract_eq}}. #' +#' @method print equation #' @export #' #' @param x 'LaTeX' equation built with \code{\link{extract_eq}} #' @param ... not used -#' +#' @return The unmodified object 'x' is returned invisibly. The function is +#' used for its side effect of printing the equation. print.equation <- function(x, ...) { cat(format(x), sep = "") + invisible(x) } -#' Print 'LaTeX' equations in Rmarkdown environments +#' Print 'LaTeX' equations in R Markdown environments #' -#' Print 'LaTeX' equations built with \code{\link{extract_eq}} nicely in Rmarkdown environments. +#' Print 'LaTeX' equations built with \code{\link{extract_eq}} nicely in R Markdown environments. #' -#' @keywords internal +#' @method knit_print equation #' @export #' #' @param x 'LaTeX' equation built with \code{\link{extract_eq}} #' @param ... not used -#' -#' @method knit_print equation +#' @param tex_packages A string with LaTeX code to include in the header, +#' usually to include LaTeX packages in the output. +#' +#' @return A string with the equation formatted according to R Markdown's output +#' format (different output for HTML, PDF, docx, gfm, markdown_strict). The +#' format is detected automatically, so, you do not have to worry about it. #' #' @importFrom knitr knit_print asis_output -#' @noRd #' knit_print.equation <- function(x, ..., tex_packages = "\\renewcommand*\\familydefault{\\rmdefault}") { eq <- format(x) @@ -62,17 +66,23 @@ is_texPreview_installed <- function() { } -#' format 'LaTeX' equations +#' Format 'LaTeX' equations #' -#' format 'LaTeX' equations built with \code{\link{extract_eq}}. +#' Format 'LaTeX' equations built with \code{\link{extract_eq}}. #' #' @export +#' @method format equation #' #' @param x 'LaTeX' equation built with \code{\link{extract_eq}} #' @param ... not used -#' @noRd -format.equation <- function(x, ...) { - if (is_latex_output()) { +#' @param latex Logical, whether the output is LaTeX or not. The default +#' value uses {knitr} to determine the current output format. +#' @return A character string with the equation formatted either as proper +#' LaTeX code, or as a display equation tag (surrounded by `$$...$$`) for R +#' Markdown or Quarto documents. +#' +format.equation <- function(x, ..., latex = knitr::is_latex_output()) { + if (isTRUE(latex)) { header <- paste0(attr(x, "latex_define_colors"), collapse = "\n") eq <- paste0(c("\n\n\\begin{equation}\n", x, "\n\\end{equation}")) paste0(c(header, eq)) diff --git a/R/shiny.R b/R/shiny.R index a612126..69d157c 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -1,9 +1,8 @@ #' Display equations in shiny apps #' #' `r lifecycle::badge("experimental")` -#' #' These are a set of functions designed to help render equations in -#' [shiny][shiny] applications. For a complete example see +#' [shiny][shiny] applications (see the vignette about Shiny). #' #' @param expr An R expression, specifically a call to [extract_eq()] #' @param outputId The identifier of the output from the server. Should be @@ -11,6 +10,9 @@ #' @param env The environment #' @param quoted Is the expresion quoted? #' @param outputArgs list of output arguments +#' +#' @return Render the equation in a suitable way for Shiny for [renderEq()] in +#' an [eqOutput()] equation output element that can be included in a panel. #' @export #' diff --git a/equatiomatic.Rproj b/equatiomatic.Rproj index 1718aeb..ffe703e 100644 --- a/equatiomatic.Rproj +++ b/equatiomatic.Rproj @@ -18,4 +18,4 @@ BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageCheckArgs: --as-cran -PackageRoxygenize: rd,collate,namespace +PackageRoxygenize: rd,collate,namespace,vignette diff --git a/inst/WORDLIST b/inst/WORDLIST index a0df716..66dfcac 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -33,6 +33,7 @@ columbia covr covrpage darwin +docx edu eq equatiomatic’ @@ -40,8 +41,10 @@ expresion frac gelman geoms +gfm ggplot glm +glmerMod greek http knitr @@ -50,6 +53,7 @@ lifecycle lm lme lmer +lmerMod macOS magrittr mapply diff --git a/man/add_se.Rd b/man/add_se.Rd deleted file mode 100644 index aed2abb..0000000 --- a/man/add_se.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/extract_eq.R -\name{add_se} -\alias{add_se} -\title{Add Standard Errors Below Coefficients} -\usage{ -add_se(coef, model) -} -\arguments{ -\item{coef}{character vector of model coefficients (from output of the function create_eq)} - -\item{model}{a fitted model} -} -\value{ -a character vector adding the errors beneath each term -} -\description{ -Add Standard Errors Below Coefficients -} diff --git a/man/extract_eq.Rd b/man/extract_eq.Rd index b839dc6..8edf06d 100644 --- a/man/extract_eq.Rd +++ b/man/extract_eq.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/extract_eq.R \name{extract_eq} \alias{extract_eq} -\title{'LaTeX' code for R models} +\title{'LaTeX' equation for R models} \usage{ extract_eq( model, @@ -27,7 +27,7 @@ extract_eq( coef_digits = 2, fix_signs = TRUE, font_size = NULL, - mean_separate, + mean_separate = NULL, return_variances = FALSE, se_subscripts = FALSE, ... @@ -152,10 +152,19 @@ This is supported for lm and glm models.} A character of class \dQuote{equation}. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}} -Extract the variable names from a model to produce a 'LaTeX' equation, which is -output to the screen. Supports any model supported by -\link[broom:reexports]{broom::tidy}. +Extract the variable names from a model to produce a 'LaTeX' equation. +Supports any model where there is a \code{\link[broom:reexports]{broom::tidy()}} method. This is a generic +function with methods for lmerMod objects obtained with \code{\link[lme4:lmer]{lme4::lmer()}}, +glmerMod objects with \code{\link[lme4:glmer]{lme4::glmer()}}, forecast_ARIMA with +\code{\link[forecast:Arima]{forecast::Arima()}} and default, with the later further covering most "base" +R models implemented in \code{\link[broom:reexports]{broom::tidy()}} like lm objects with \code{\link[stats:lm]{stats::lm()}}, +glm objects with \code{\link[stats:glm]{stats::glm()}} or polr objects with \code{\link[MASS:polr]{MASS::polr()}}. The +default method also supports clm objects obtained with \code{\link[ordinal:clm]{ordinal::clm()}}. +} +\details{ +The different methods all use the same arguments, but not all arguments are +suitable to all models. Check here above to determine if a feature is +implemented for a given model. } \examples{ # Simple model diff --git a/man/fix_coef_signs_se.Rd b/man/fix_coef_signs_se.Rd deleted file mode 100644 index fc02d54..0000000 --- a/man/fix_coef_signs_se.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/extract_eq.R -\name{fix_coef_signs_se} -\alias{fix_coef_signs_se} -\title{Fixes the Signs When Using se_subscripts Argument} -\usage{ -fix_coef_signs_se(equation) -} -\arguments{ -\item{equation}{list that contains the equation} -} -\value{ -a list containing the equation with fixed signs -} -\description{ -Fixes the Signs When Using se_subscripts Argument -} diff --git a/man/format.equation.Rd b/man/format.equation.Rd new file mode 100644 index 0000000..ab7b99c --- /dev/null +++ b/man/format.equation.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/print.R +\name{format.equation} +\alias{format.equation} +\title{Format 'LaTeX' equations} +\usage{ +\method{format}{equation}(x, ..., latex = knitr::is_latex_output()) +} +\arguments{ +\item{x}{'LaTeX' equation built with \code{\link{extract_eq}}} + +\item{...}{not used} + +\item{latex}{Logical, whether the output is LaTeX or not. The default +value uses {knitr} to determine the current output format.} +} +\value{ +A character string with the equation formatted either as proper +LaTeX code, or as a display equation tag (surrounded by \verb{$$...$$}) for R +Markdown or Quarto documents. +} +\description{ +Format 'LaTeX' equations built with \code{\link{extract_eq}}. +} diff --git a/man/knit_print.equation.Rd b/man/knit_print.equation.Rd new file mode 100644 index 0000000..2588a6d --- /dev/null +++ b/man/knit_print.equation.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/print.R +\name{knit_print.equation} +\alias{knit_print.equation} +\title{Print 'LaTeX' equations in R Markdown environments} +\usage{ +\method{knit_print}{equation}( + x, + ..., + tex_packages = "\\\\renewcommand*\\\\familydefault{\\\\rmdefault}" +) +} +\arguments{ +\item{x}{'LaTeX' equation built with \code{\link{extract_eq}}} + +\item{...}{not used} + +\item{tex_packages}{A string with LaTeX code to include in the header, +usually to include LaTeX packages in the output.} +} +\value{ +A string with the equation formatted according to R Markdown's output +format (different output for HTML, PDF, docx, gfm, markdown_strict). The +format is detected automatically, so, you do not have to worry about it. +} +\description{ +Print 'LaTeX' equations built with \code{\link{extract_eq}} nicely in R Markdown environments. +} diff --git a/man/print.equation.Rd b/man/print.equation.Rd index 2fd4c25..b07740b 100644 --- a/man/print.equation.Rd +++ b/man/print.equation.Rd @@ -11,9 +11,10 @@ \item{...}{not used} } -\description{ -lifecycle::badge("stable")` +\value{ +The unmodified object 'x' is returned invisibly. The function is +used for its side effect of printing the equation. } -\details{ +\description{ Print 'LaTeX' equations built with \code{\link{extract_eq}}. } diff --git a/man/renderEq.Rd b/man/renderEq.Rd index 2342a5c..3cfb2bc 100644 --- a/man/renderEq.Rd +++ b/man/renderEq.Rd @@ -21,12 +21,14 @@ eqOutput(outputId) \item{outputId}{The identifier of the output from the server. Should be passed as a string.} } +\value{ +Render the equation in a suitable way for Shiny for \code{\link[=renderEq]{renderEq()}} in +an \code{\link[=eqOutput]{eqOutput()}} equation output element that can be included in a panel. +} \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -} -\details{ These are a set of functions designed to help render equations in -\link{shiny} applications. For a complete example see +\link{shiny} applications (see the vignette about Shiny). } \section{Functions}{ \itemize{ diff --git a/tests/testthat/test-glmerMod.R b/tests/testthat/test-glmerMod.R index bd203a2..a9f7b1f 100644 --- a/tests/testthat/test-glmerMod.R +++ b/tests/testthat/test-glmerMod.R @@ -40,6 +40,7 @@ test_that("colorizing works", { ) ) + suppressWarnings( expect_warning( extract_eq( m, @@ -58,6 +59,7 @@ test_that("colorizing works", { greek_colors = rainbow(7) ) ) + ) }) test_that("Renaming Variables works", {