-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
179 lines (116 loc) · 3.61 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
output: github_document
always_allow_html: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.width=6, fig.height=3.5,
fig.showtext = TRUE,dpi = 300)
```
# idstyle
<!-- badges: start -->
[![R-CMD-check](https://github.com/wf-id/idstyle/workflows/R-CMD-check/badge.svg)](https://github.com/wf-id/idstyle/actions)
<!-- badges: end -->
The goal of idstyle is to ...
## Installation
You can install the development version of idstyle like so:
``` r
remotes::install_github("wf-id/idstyle")
```
## Examples
### Tables
Flextable formatting:
- Black & white (default)
```{r}
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(idstyle))
head(mtcars) |> format_flex_table()
```
- "wake" color
```{r}
head(mtcars) |> format_flex_table(color = 'wake')
```
### Plots
- Points with black default
```{r}
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point()
```
- Points with continuous default
```{r}
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point(aes(color = gear))
```
- ID colorblind safe palette for factors
```{r}
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
```
- ID colorblind safe palette for continuous fill
```{r}
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
```{r}
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
```{r}
gg2 + theme_wake(grid = 'both') +
labs(title = 'Now with grids!')
```
- Facets
```{r}
gg2 + facet_wrap(~gear) + theme_id_facet(grid = 'y') +
labs(title = 'Some facets! And y grids only')
```
- Interactive
```{r eval=knitr::is_html_output()}
plotly::ggplotly(gg2)
```
- Theme Updating (ggplot2 default)
```{r}
theme_set_gg()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
```
- Theme Updating (Wake default)
```{r}
theme_set_wake()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
```
- Theme Updating (Atrium default)
```{r}
theme_set_atrium()
ggplot(mtcars) + geom_bar(aes(x = carb, fill = factor(carb)))
theme_set_id() # back to normal default
```
- Font Awesome
```{r}
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.