The goal of idstyle is to …
You can install the development version of idstyle like so:
remotes::install_github("wf-id/idstyle")
Flextable formatting:
- Black & white (default)
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(idstyle))
head(mtcars) |> format_flex_table()
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb |
---|---|---|---|---|---|---|---|---|---|---|
21.0 | 6 | 160 | 110 | 3.9 | 2.6 | 16.5 | 0 | 1 | 4 | 4 |
21.0 | 6 | 160 | 110 | 3.9 | 2.9 | 17.0 | 0 | 1 | 4 | 4 |
22.8 | 4 | 108 | 93 | 3.8 | 2.3 | 18.6 | 1 | 1 | 4 | 1 |
21.4 | 6 | 258 | 110 | 3.1 | 3.2 | 19.4 | 1 | 0 | 3 | 1 |
18.7 | 8 | 360 | 175 | 3.1 | 3.4 | 17.0 | 0 | 0 | 3 | 2 |
18.1 | 6 | 225 | 105 | 2.8 | 3.5 | 20.2 | 1 | 0 | 3 | 1 |
- “wake” color
head(mtcars) |> format_flex_table(color = 'wake')
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb |
---|---|---|---|---|---|---|---|---|---|---|
21.0 | 6 | 160 | 110 | 3.9 | 2.6 | 16.5 | 0 | 1 | 4 | 4 |
21.0 | 6 | 160 | 110 | 3.9 | 2.9 | 17.0 | 0 | 1 | 4 | 4 |
22.8 | 4 | 108 | 93 | 3.8 | 2.3 | 18.6 | 1 | 1 | 4 | 1 |
21.4 | 6 | 258 | 110 | 3.1 | 3.2 | 19.4 | 1 | 0 | 3 | 1 |
18.7 | 8 | 360 | 175 | 3.1 | 3.4 | 17.0 | 0 | 0 | 3 | 2 |
18.1 | 6 | 225 | 105 | 2.8 | 3.5 | 20.2 | 1 | 0 | 3 | 1 |
- Points with black default
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point()
- Points with continuous default
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point(aes(color = gear))
- ID colorblind safe palette for factors
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
- ID colorblind safe palette for continuous fill
if (requireNamespace("sf", quietly = TRUE)) {
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
geom_sf(aes(fill = AREA))
}
- Label formatting
gg2 <- mtcars |> ggplot(aes(x = mpg, y = hp, color = cut(mtcars$hp,6))) + #discrete scale
geom_point() + labs(title = 'This is a title for my graph',
subtitle = 'This is a subtitle for my graph',
caption = 'This is a caption for my graph',
color = 'HP')
gg2
- Grids
gg2 + theme_wake(grid = 'both') +
labs(title = 'Now with grids!')
- Facets
gg2 + facet_wrap(~gear) + theme_id_facet(grid = 'y') +
labs(title = 'Some facets! And y grids only')
- Interactive
plotly::ggplotly(gg2)
- Theme Updating (ggplot2 default)
theme_set_gg()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
- Theme Updating (Wake default)
theme_set_wake()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
- Theme Updating (Atrium default)
theme_set_atrium()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
theme_set_id() # back to normal default
- Font Awesome
mtcars |> ggplot(aes(x = mpg, y = hp)) +
geom_fontawesome('head-side-virus', size = 10) +
labs(title = 'Using a font awesome icon')
mtcars |>
mutate(myicon = if_else(am==0, 'robot','user')) |>
ggplot(aes(x = mpg, y = hp, color = factor(gear), fill = factor(gear))) +
geom_fontawesome(myicon, size = 10) +
labs(title = 'Using font awesome icons in dataset') +
guides(color = guide_legend(override.aes = aes(label = "■"))
) #otherwise "a" is in legend
You should not rely on this Website for medical advice or guidance.
The Website relies upon publicly available data that do not always agree. Authors hereby disclaims any and all representations and warranties with respect to the Website, including accuracy, fitness for use, reliability, completeness, and non-infringement of third party rights.
These terms and conditions are subject to change. Your use of the Website constitutes your acceptance of these terms and conditions and any future modifications thereof.