Skip to content
/ idstyle Public

R package for templates and styles

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

wf-id/idstyle

Repository files navigation

idstyle

R-CMD-check

The goal of idstyle is to …

Installation

You can install the development version of idstyle like so:

remotes::install_github("wf-id/idstyle")

Examples

Tables

Flextable formatting:

  • Black & white (default)
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(idstyle))
head(mtcars) |> format_flex_table() 
<style>.cl-a111604e{}.cl-a0f0dd1a{font-family:'Arial';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-a0f0dd6a{font-family:'Arial';font-size:10pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-a0fbeebc{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-a0fc25a8{width:0.509in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 1.5pt solid rgba(102, 102, 102, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a0fc25b2{width:0.509in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a0fc25bc{width:0.509in;background-color:transparent;vertical-align: middle;border-bottom: 1.5pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style>

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') 
<style>.cl-a1abd5fc{}.cl-a18cc5d6{font-family:'Arial';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(255, 255, 255, 1.00);background-color:transparent;}.cl-a18cc5ea{font-family:'Arial';font-size:10pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-a1990e68{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-a19987f8{width:0.509in;background-color:rgba(140, 109, 44, 1.00);vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a199880c{width:0.509in;background-color:rgba(239, 239, 239, 1.00);vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-a199880d{width:0.509in;background-color:transparent;vertical-align: middle;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style>

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

Plots

  • 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

Terms of Use

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.

About

R package for templates and styles

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published