fix: correct pipe precedence docs — |> binds tighter than +
R-CMD-check / R CMD check (push) Successful in 2m46s
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:
@@ -190,8 +190,11 @@ test_that("civilytics_logo returns a grob", {
|
||||
})
|
||||
|
||||
test_that("civilytics_logo works with pipe operator", {
|
||||
p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()
|
||||
result <- suppressWarnings(p |> civilytics_logo())
|
||||
# |> has higher precedence than +, so parens are required
|
||||
result <- suppressWarnings(
|
||||
(ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_civilytics()) |>
|
||||
civilytics_logo()
|
||||
)
|
||||
expect_s3_class(result, "grob")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user