2025-11-19 13:25:44 +00:00
|
|
|
|
# Easily plot euler diagrams
|
|
|
|
|
|
|
|
|
|
|
|
Easily plot euler diagrams
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
``` r
|
2026-03-24 12:02:27 +00:00
|
|
|
|
plot_euler(data, pri, sec, ter = NULL, seed = 2103, color.palette = "viridis")
|
2025-11-19 13:25:44 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Arguments
|
|
|
|
|
|
|
|
|
|
|
|
- data:
|
|
|
|
|
|
|
|
|
|
|
|
data
|
|
|
|
|
|
|
|
|
|
|
|
- seed:
|
|
|
|
|
|
|
|
|
|
|
|
seed
|
|
|
|
|
|
|
|
|
|
|
|
- x:
|
|
|
|
|
|
|
|
|
|
|
|
name of main variable
|
|
|
|
|
|
|
|
|
|
|
|
- y:
|
|
|
|
|
|
|
|
|
|
|
|
name of secondary variables
|
|
|
|
|
|
|
|
|
|
|
|
- z:
|
|
|
|
|
|
|
|
|
|
|
|
grouping variable
|
|
|
|
|
|
|
|
|
|
|
|
## Value
|
|
|
|
|
|
|
|
|
|
|
|
patchwork object
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
|
|
``` r
|
|
|
|
|
|
data.frame(
|
|
|
|
|
|
A = sample(c(TRUE, TRUE, FALSE), 50, TRUE),
|
|
|
|
|
|
B = sample(c("A", "C"), 50, TRUE),
|
|
|
|
|
|
C = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE),
|
|
|
|
|
|
D = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE)
|
|
|
|
|
|
) |> plot_euler("A", c("B", "C"), "D", seed = 4)
|
2026-05-27 18:45:46 +00:00
|
|
|
|
#> Error in dplyr::mutate(data$centers, label = purrr::map2(labels, quantities, ~{ if (!is.na(.x) && !is.na(.y) && show_labels) { paste0(.x, "\n", sprintf(.y, fmt = "%.4g")) } else if (!is.na(.x) && show_labels) { .x } else if (!is.na(.y)) { .y } else { "" } })): ℹ In argument: `label = purrr::map2(...)`.
|
|
|
|
|
|
#> Caused by error in `purrr::map2()`:
|
|
|
|
|
|
#> ℹ In index: 1.
|
|
|
|
|
|
#> Caused by error in `sprintf()`:
|
|
|
|
|
|
#> ! invalid format '%.4g'; use format %s for character objects
|
2025-11-19 13:25:44 +00:00
|
|
|
|
mtcars |> plot_euler("vs", "am", seed = 1)
|
2026-05-27 18:45:46 +00:00
|
|
|
|
#> Error in dplyr::mutate(data$centers, label = purrr::map2(labels, quantities, ~{ if (!is.na(.x) && !is.na(.y) && show_labels) { paste0(.x, "\n", sprintf(.y, fmt = "%.4g")) } else if (!is.na(.x) && show_labels) { .x } else if (!is.na(.y)) { .y } else { "" } })): ℹ In argument: `label = purrr::map2(...)`.
|
|
|
|
|
|
#> Caused by error in `purrr::map2()`:
|
|
|
|
|
|
#> ℹ In index: 1.
|
|
|
|
|
|
#> Caused by error in `sprintf()`:
|
|
|
|
|
|
#> ! invalid format '%.4g'; use format %s for character objects
|
2025-11-19 13:25:44 +00:00
|
|
|
|
mtcars |> plot_euler("vs", "am", "cyl", seed = 1)
|
2026-05-27 18:45:46 +00:00
|
|
|
|
#> Error in dplyr::mutate(data$centers, label = purrr::map2(labels, quantities, ~{ if (!is.na(.x) && !is.na(.y) && show_labels) { paste0(.x, "\n", sprintf(.y, fmt = "%.4g")) } else if (!is.na(.x) && show_labels) { .x } else if (!is.na(.y)) { .y } else { "" } })): ℹ In argument: `label = purrr::map2(...)`.
|
|
|
|
|
|
#> Caused by error in `purrr::map2()`:
|
|
|
|
|
|
#> ℹ In index: 1.
|
|
|
|
|
|
#> Caused by error in `sprintf()`:
|
|
|
|
|
|
#> ! invalid format '%.4g'; use format %s for character objects
|
2025-11-19 13:25:44 +00:00
|
|
|
|
stRoke::trial |>
|
|
|
|
|
|
dplyr::mutate(
|
|
|
|
|
|
mfi_cut = cut(mfi_6, c(0, 12, max(mfi_6, na.rm = TRUE))),
|
|
|
|
|
|
mdi_cut = cut(mdi_6, c(0, 20, max(mdi_6, na.rm = TRUE)))
|
|
|
|
|
|
) |>
|
|
|
|
|
|
purrr::map2(
|
|
|
|
|
|
c(sapply(stRoke::trial, \(.x)REDCapCAST::get_attr(.x, attr = "label")), "Fatigue", "Depression"),
|
|
|
|
|
|
\(.x, .y){
|
|
|
|
|
|
REDCapCAST::set_attr(.x, .y, "label")
|
|
|
|
|
|
}
|
|
|
|
|
|
) |>
|
|
|
|
|
|
dplyr::bind_cols() |>
|
|
|
|
|
|
plot_euler("mfi_cut", "mdi_cut")
|
2026-05-27 18:45:46 +00:00
|
|
|
|
#> Error in dplyr::mutate(data$centers, label = purrr::map2(labels, quantities, ~{ if (!is.na(.x) && !is.na(.y) && show_labels) { paste0(.x, "\n", sprintf(.y, fmt = "%.4g")) } else if (!is.na(.x) && show_labels) { .x } else if (!is.na(.y)) { .y } else { "" } })): ℹ In argument: `label = purrr::map2(...)`.
|
|
|
|
|
|
#> Caused by error in `purrr::map2()`:
|
|
|
|
|
|
#> ℹ In index: 1.
|
|
|
|
|
|
#> Caused by error in `sprintf()`:
|
|
|
|
|
|
#> ! invalid format '%.4g'; use format %s for character objects
|
2025-11-19 13:25:44 +00:00
|
|
|
|
stRoke::trial |>
|
|
|
|
|
|
plot_euler(pri="male", sec=c("hypertension"))
|
2026-05-27 18:45:46 +00:00
|
|
|
|
#> Error in dplyr::mutate(data$centers, label = purrr::map2(labels, quantities, ~{ if (!is.na(.x) && !is.na(.y) && show_labels) { paste0(.x, "\n", sprintf(.y, fmt = "%.4g")) } else if (!is.na(.x) && show_labels) { .x } else if (!is.na(.y)) { .y } else { "" } })): ℹ In argument: `label = purrr::map2(...)`.
|
|
|
|
|
|
#> Caused by error in `purrr::map2()`:
|
|
|
|
|
|
#> ℹ In index: 1.
|
|
|
|
|
|
#> Caused by error in `sprintf()`:
|
|
|
|
|
|
#> ! invalid format '%.4g'; use format %s for character objects
|
2025-11-19 13:25:44 +00:00
|
|
|
|
```
|