Skip to content

Commit 9a361bd

Browse files
authoredMar 9, 2025··
Reduce usage of pipes in the docs and tests (#389)
* Reduce usage of pipes in the docs and tests Fixes #276 * styler /whitespace
1 parent 222a854 commit 9a361bd

8 files changed

+77
-40
lines changed
 

‎DESCRIPTION

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: see
33
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
4-
Version: 0.10.0.8
4+
Version: 0.10.0.9
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -102,7 +102,6 @@ Suggests:
102102
metafor,
103103
NbClust,
104104
nFactors,
105-
poorman,
106105
psych,
107106
qqplotr (>= 0.0.6),
108107
randomForest,

‎README.Rmd

+17-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ csl: apa.csl
77
# see: Model Visualisation Toolbox for 'easystats' and 'ggplot2' <img src='man/figures/logo.png' align="right" height="139" />
88

99
```{r, echo=FALSE, warning=FALSE, message=FALSE}
10-
library(poorman)
1110
library(see)
1211
1312
knitr::opts_chunk$set(
@@ -267,7 +266,7 @@ p2 <- ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
267266
p3 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Sepal.Length)) +
268267
geom_point2() +
269268
theme_modern() +
270-
scale_color_material_c(palette = "rainbow")
269+
scale_color_material(discrete = FALSE)
271270
```
272271

273272
## Multiple plots
@@ -321,16 +320,25 @@ ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
321320
## Radar chart (Spider plot)
322321

323322
```{r}
324-
library(poorman)
325323
library(datawizard)
326324
327325
# prepare the data in tidy format
328-
data <- iris %>%
329-
group_by(Species) %>%
330-
summarise(across(everything(), mean)) %>%
331-
reshape_longer(c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"))
332-
333-
data %>%
326+
data <- iris |>
327+
datawizard::data_group("Species") |>
328+
datawizard::data_summary(
329+
Sepal.Length = mean(Sepal.Length),
330+
Sepal.Width = mean(Sepal.Width),
331+
Petal.Length = mean(Petal.Length),
332+
Petal.Width = mean(Petal.Width)
333+
) |>
334+
datawizard::reshape_longer(c(
335+
"Sepal.Length",
336+
"Sepal.Width",
337+
"Petal.Length",
338+
"Petal.Width"
339+
))
340+
341+
data |>
334342
ggplot(aes(
335343
x = name,
336344
y = value,

‎README.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ p2 <- ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
325325
p3 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Sepal.Length)) +
326326
geom_point2() +
327327
theme_modern() +
328-
scale_color_material_c(palette = "rainbow")
328+
scale_color_material(discrete = FALSE)
329329
```
330330

331331
## Multiple plots
@@ -388,16 +388,25 @@ ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
388388
## Radar chart (Spider plot)
389389

390390
``` r
391-
library(poorman)
392391
library(datawizard)
393392

394393
# prepare the data in tidy format
395-
data <- iris %>%
396-
group_by(Species) %>%
397-
summarise(across(everything(), mean)) %>%
398-
reshape_longer(c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"))
399-
400-
data %>%
394+
data <- iris |>
395+
datawizard::data_group("Species") |>
396+
datawizard::data_summary(
397+
Sepal.Length = mean(Sepal.Length),
398+
Sepal.Width = mean(Sepal.Width),
399+
Petal.Length = mean(Petal.Length),
400+
Petal.Width = mean(Petal.Width)
401+
) |>
402+
datawizard::reshape_longer(c(
403+
"Sepal.Length",
404+
"Sepal.Width",
405+
"Petal.Length",
406+
"Petal.Width"
407+
))
408+
409+
data |>
401410
ggplot(aes(
402411
x = name,
403412
y = value,

‎man/figures/unnamed-chunk-10-1.png

-249 Bytes
Loading

‎man/figures/unnamed-chunk-9-1.png

-279 Bytes
Loading

‎tests/testthat/test-vdiffr_themes.R

+31-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1+
skip_if_not_installed("vdiffr")
2+
13
test_that("theme functions work", {
2-
skip_if_not_installed("poorman")
3-
suppressPackageStartupMessages(library(poorman))
4+
skip_if(getRversion() < "4.1.0")
45

5-
data <- iris %>%
6-
group_by(Species) %>%
7-
summarise(across(everything(), mean)) %>%
8-
datawizard::reshape_longer(c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"))
6+
data <- iris |>
7+
datawizard::data_group("Species") |>
8+
datawizard::data_summary(
9+
Sepal.Length = mean(Sepal.Length),
10+
Sepal.Width = mean(Sepal.Width),
11+
Petal.Length = mean(Petal.Length),
12+
Petal.Width = mean(Petal.Width)
13+
) |>
14+
datawizard::reshape_longer(c(
15+
"Sepal.Length",
16+
"Sepal.Width",
17+
"Petal.Length",
18+
"Petal.Width"
19+
))
920

1021
set.seed(123)
1122
vdiffr::expect_doppelganger(
1223
title = "theme_radar works",
1324
fig = ggplot(
14-
data, aes(
25+
data,
26+
aes(
1527
x = name,
1628
y = value,
1729
color = Species,
@@ -30,23 +42,32 @@ test_that("theme functions work", {
3042
set.seed(123)
3143
vdiffr::expect_doppelganger(
3244
title = "theme_modern works",
33-
fig = ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
45+
fig = ggplot(
46+
iris,
47+
aes(x = Sepal.Width, y = Sepal.Length, color = Species)
48+
) +
3449
geom_point() +
3550
theme_modern()
3651
)
3752

3853
set.seed(123)
3954
vdiffr::expect_doppelganger(
4055
title = "theme_modern with ticks works",
41-
fig = ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
56+
fig = ggplot(
57+
iris,
58+
aes(x = Sepal.Width, y = Sepal.Length, color = Species)
59+
) +
4260
geom_point() +
4361
theme_modern(show.ticks = TRUE)
4462
)
4563

4664
set.seed(123)
4765
vdiffr::expect_doppelganger(
4866
title = "theme_modern works with base_size",
49-
fig = ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
67+
fig = ggplot(
68+
iris,
69+
aes(x = Sepal.Width, y = Sepal.Length, color = Species)
70+
) +
5071
geom_point() +
5172
theme_modern(base_size = 20)
5273
)

‎vignettes/correlation.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ knitr::opts_chunk$set(
1717
message = FALSE
1818
)
1919
20-
pkgs <- c("correlation", "ggplot2", "ggraph", "poorman")
20+
pkgs <- c("correlation", "ggplot2", "ggraph")
2121
successfully_loaded <- vapply(pkgs, requireNamespace, FUN.VALUE = logical(1L), quietly = TRUE)
2222
can_evaluate <- all(successfully_loaded)
2323

‎vignettes/effectsize.Rmd

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ knitr::opts_chunk$set(
1717
message = FALSE
1818
)
1919
20-
pkgs <- c("effectsize", "ggplot2", "poorman")
20+
pkgs <- c("effectsize", "ggplot2")
2121
successfully_loaded <- vapply(pkgs, requireNamespace, FUN.VALUE = logical(1L), quietly = TRUE)
2222
can_evaluate <- all(successfully_loaded)
2323
24-
if (can_evaluate) {
24+
if (can_evaluate && getRversion() >= "4.1.0") {
2525
knitr::opts_chunk$set(eval = TRUE)
2626
vapply(pkgs, require, FUN.VALUE = logical(1L), quietly = TRUE, character.only = TRUE)
2727
} else {
@@ -55,12 +55,12 @@ data(iris)
5555
_([related function documentation](https://easystats.github.io/effectsize/reference/eta_squared.html))_
5656

5757
```{r}
58-
aov(mpg ~ factor(am) * factor(cyl), data = mtcars) %>%
59-
eta_squared() %>%
58+
aov(mpg ~ factor(am) * factor(cyl), data = mtcars) |>
59+
eta_squared() |>
6060
plot()
6161
6262
63-
t_to_d(t = c(1, -1.3, -3, 2.3), df_error = c(40, 35, 40, 85)) %>%
63+
t_to_d(t = c(1, -1.3, -3, 2.3), df_error = c(40, 35, 40, 85)) |>
6464
plot()
6565
```
6666

@@ -69,13 +69,13 @@ t_to_d(t = c(1, -1.3, -3, 2.3), df_error = c(40, 35, 40, 85)) %>%
6969
_([related function documentation](https://easystats.github.io/effectsize/reference/equivalence_test.effectsize_table.html))_
7070

7171
```{r}
72-
aov(mpg ~ factor(am) * factor(cyl), data = mtcars) %>%
73-
eta_squared() %>%
74-
equivalence_test(range = 0.3) %>%
72+
aov(mpg ~ factor(am) * factor(cyl), data = mtcars) |>
73+
eta_squared() |>
74+
equivalence_test(range = 0.3) |>
7575
plot()
7676
7777
78-
t_to_d(t = c(1, -1.3, -3, 2.3), df_error = c(40, 35, 40, 85)) %>%
79-
equivalence_test(range = 1) %>%
78+
t_to_d(t = c(1, -1.3, -3, 2.3), df_error = c(40, 35, 40, 85)) |>
79+
equivalence_test(range = 1) |>
8080
plot()
8181
```

0 commit comments

Comments
 (0)
Please sign in to comment.