fix: correct pipe precedence docs — |> binds tighter than +
R-CMD-check / R CMD check (push) Successful in 2m46s

R's |> has higher precedence than +, so parentheses ARE required
around the ggplot chain before piping to civilytics_logo():

  (ggplot(df, aes(x, y)) + geom_point() + theme_civilytics()) |>
    civilytics_logo()

Updated docs, examples, and pipe test accordingly.
This commit is contained in:
2026-05-17 22:54:53 -06:00
parent 7371069379
commit 099fff1d1d
4 changed files with 28 additions and 24 deletions
+11 -11
View File
@@ -29,34 +29,34 @@ A grob (from [gridExtra::arrangeGrob()]) ready to draw with
}
\description{
A convenience wrapper that creates the logo grob and attaches it below the
plot in one call. Designed for use with the base pipe `|>`:
plot in one call. Designed for use with the base pipe `|>`.
}
\details{
**Important:** R's `|>` has *higher* precedence than `+`, so you must
wrap the ggplot chain in parentheses before piping:
```
ggplot(mpg, aes(displ, hwy)) +
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics() |>
theme_civilytics()) |>
civilytics_logo()
```
Since `|>` has lower precedence than `+`, the entire ggplot chain is piped
as the first argument — no parentheses needed.
}
\examples{
\dontrun{
library(ggplot2); library(grid)
# Pipe-friendly usage
ggplot(mpg, aes(displ, hwy)) +
# Pipe usage — parentheses required around the ggplot chain
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics() |>
theme_civilytics()) |>
civilytics_logo() |>
grid.draw()
# Dark theme with mark
ggplot(mpg, aes(displ, hwy)) +
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics_dark() |>
theme_civilytics_dark()) |>
civilytics_logo(variant = "dark", type = "mark") |>
grid.draw()
}