Skip to content

Commit 6b5a7d2

Browse files
committed
Add if (interactive()) to examples that rely on a web browser
1 parent c946ed1 commit 6b5a7d2

File tree

6 files changed

+31
-18
lines changed

6 files changed

+31
-18
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: equatiomatic
22
Title: Transform Models into 'LaTeX' Equations
3-
Version: 0.4.3
3+
Version: 0.4.4
44
Authors@R:
55
c(person(given = "Daniel",
66
family = "Anderson",

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# equatiomatic 0.4.4
2+
3+
* Adding `if (interactive())` where a preview of the equation is generated in a
4+
Web browser to avoid a note in CRAN check.
5+
16
# equatiomatic 0.4.3
27

38
* Correction of an URL that has no valid certificate in lme4-lmer vignette.

R/equation.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@
4545
#' # Print raw text:
4646
#' eq1
4747
#' # Get a preview of the equation
48-
#' eq__(eq1)
48+
#' if (interactive())
49+
#' eq__(eq1)
4950
#' # The same function can be used inside a `$$...$$ {#eq-label}` construct in
5051
#' # R Markdown or Quarto to calcule a display equation that is also recognized
5152
#' # by the cross referencing system of Quarto.
5253
#' # Get a string suitable for inclusion inline in R Markdown with `r eq__(eq1)`
5354
#' # (inside Markdown text and without the dollar signs around it)
5455
#' # For inline equations in a Markdown text, you are better to use `r eq_(eq1)`
55-
#' eq_(eq1)
56+
#' if (interactive())
57+
#' eq_(eq1)
5658
equation <- function(object, ...) {
5759
UseMethod("equation")
5860
}
@@ -187,7 +189,7 @@ print.inline_equation <- function(x, ...) {
187189
# extract the exponent of I()
188190
vec <- sub("^I\\(.*(\\^.*)\\).*", "\\1", names(labels)[i])
189191

190-
if(isTRUE(units)) {
192+
if (isTRUE(units)) {
191193
# vec[i] <- sub(" \\n", paste0(sous_chaine, "\\\n"), vec[i])
192194
labels[i] <- gsub("(.*)(\\n \\[)(.*)(\\])",
193195
paste0("\\1", vec, "\\2", "\\3", vec,"\\4"), labels[i])

R/print.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ format.equation <- function(x, ..., latex = knitr::is_latex_output()) {
8080
#' @export
8181
#'
8282
#' @examples
83-
#' mod1 <- lm(mpg ~ cyl + disp, mtcars)
84-
#' eq1 <- extract_eq(mod1)
85-
#' eq1 # Not that nice
86-
#' preview_eq(eq1)
87-
#' # or easier...
88-
#' preview_eq(mod1)
83+
#' if (interactive()) {
84+
#' mod1 <- lm(mpg ~ cyl + disp, mtcars)
85+
#' eq1 <- extract_eq(mod1)
86+
#' eq1 # Not that nice
87+
#' preview_eq(eq1)
88+
#' # or easier...
89+
#' preview_eq(mod1)
90+
#' }
8991
preview_eq <- function(x, ...) {
9092
if (!rmarkdown::pandoc_available())
9193
stop("Pandoc is not available. Please install it to use this function.",

man/equation.Rd

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/preview_eq.Rd

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)