Skip to content

Commit 8a3bd96

Browse files
committed
Suppress warnings in vignette
1 parent 9b109d8 commit 8a3bd96

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

vignettes/wbplot.Rmd

+16-15
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Now we can apply the `theme_wb` theme to the plot. This will change the used fon
8989
barchart + theme_wb()
9090
```
9191

92-
The `wb_theme()`can be added to any ggplot visualization. But the World Bank data visualization style calls for some bar chart specific styling options. We can apply those by setting by setting the `chartType` parameter to "bar" in the theme function:
92+
The `wb_theme()` can be added to any ggplot visualization. But the World Bank data visualization style calls for some bar chart specific styling options. We can apply those by setting by setting the `chartType` parameter to "bar" in the theme function:
9393

9494
```{r, fig.dim = c(8,4), dpi = 300, out.width = "100%"}
9595
barchart + theme_wb(chartType = "bar")
@@ -132,7 +132,7 @@ print(scatterdata)
132132
```
133133
With this data, we can create a default ggplot scatterplot.
134134

135-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
135+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
136136
scatterplot <- ggplot(scatterdata, aes(NY.GDP.PCAP.PP.CD, SP.DYN.LE00.IN, fill = region_iso3c)) +
137137
geom_point() +
138138
labs(
@@ -147,33 +147,33 @@ Notice that because you ran the `theme_wb()` function before, the default shape
147147

148148
Applying `theme_wb` to this plot gives you this:
149149

150-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
150+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
151151
scatterplot + theme_wb()
152152
```
153153

154154
Like for bar charts, the World Bank data visualization style has some specific styling for scatter plots:
155155

156-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
156+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
157157
scatterplot + theme_wb(chartType = "scatter")
158158
```
159159

160160
Whenever a continuous scale is present, you can include a line to indicate the zero value on the axis. When zero was not included on the axis initially, the scale will extend to include it.
161161

162-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
162+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
163163
scatterplot + theme_wb(chartType = "scatter", addXZeroLine = TRUE, addYZeroLine = TRUE)
164164
```
165165

166166
The wbplot package includes continuous and discrete color scales for the World Bank data visualization color palettes. In this case we should use the `scale_fill_wb_d` to apply the default discrete color palette to the regions.
167167

168-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
168+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
169169
scatterplot +
170170
theme_wb(chartType = "scatter", addXZeroLine = TRUE) +
171171
scale_fill_wb_d(name = "Region")
172172
```
173173

174174
Each World Bank also has a color assigned to it in the `region` palette, so we can map the region code directly to the corresponding color.
175175

176-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
176+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
177177
scatterplot +
178178
aes(fill = tolower(region_iso3c)) +
179179
theme_wb(chartType = "scatter", addXZeroLine = TRUE) +
@@ -182,7 +182,7 @@ scatterplot +
182182

183183
Income levels also have their own palette, called "income".
184184

185-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
185+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
186186
scatterplot +
187187
aes(fill = tolower(income_level_iso3c)) +
188188
theme_wb(chartType = "scatter", addXZeroLine = TRUE) +
@@ -191,25 +191,26 @@ scatterplot +
191191

192192
Alternatively, we can map the fill aesthetic to a numeric variable, and use the continuous color scale to apply a World Bank continuous color palette.
193193

194-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
194+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
195195
scatterplot +
196196
aes(fill = NY.GDP.PCAP.PP.CD) +
197197
theme_wb(chartType = "scatter", addXZeroLine = TRUE) +
198198
scale_fill_wb_c(palette = "seq", name = "GDP/capita")
199199
```
200200

201201
Binned color scales are also provided:
202-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
202+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
203203
scatterplot +
204204
aes(fill = NY.GDP.PCAP.PP.CD) +
205205
theme_wb(chartType = "scatter", addXZeroLine = TRUE) +
206206
scale_fill_wb_b(palette = "divPosNeg", name = "GDP/capita", n.breaks = 8)
207207
```
208+
208209
## Styling a line chart
209210

210211
Let's prepare some time series data and make a ggplot line chart.
211212

212-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
213+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
213214
life.series <- filter(life.expectancy, iso3c %in% c("USA", "CHN", "IND", "DEU", "RUS", "IDN", "JPN"))
214215
215216
linechart <- ggplot(life.series, aes(x = date, y = SP.DYN.LE00.IN, color = iso3c)) +
@@ -221,7 +222,7 @@ linechart
221222

222223
Applying the general `wb_theme` and the line chart specific styling to it, together with the World Bank discrete color scale:
223224

224-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
225+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
225226
linechart +
226227
theme_wb(chartType = "line", addYZeroLine = TRUE) +
227228
scale_color_wb_d() +
@@ -230,7 +231,7 @@ linechart +
230231

231232
We can give more context by providing the data for all countries in the background.
232233

233-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
234+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
234235
linechart +
235236
theme_wb(chartType = "line", addYZeroLine = TRUE) +
236237
scale_color_wb_d() +
@@ -252,7 +253,7 @@ Here you can see that all colors of the World Bank data visualization style are
252253

253254
Finally, let's create a beeswarm plot and style it. To plot a beeswarm plot, we use the ggbeeswarm package.
254255

255-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
256+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
256257
lifeexp.22 <- filter(life.expectancy, date == 2022) %>%
257258
left_join(countries, by = "iso3c") %>%
258259
filter(income_level_iso3c != "INX") %>%
@@ -270,7 +271,7 @@ beeswarm <- ggplot(lifeexp.22, ggplot2::aes(x = SP.DYN.LE00.IN, y = income_level
270271
beeswarm
271272
```
272273

273-
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%"}
274+
```{r, fig.dim = c(8,6), dpi = 300, out.width = "100%", warning = FALSE}
274275
beeswarm +
275276
theme_wb(chartType = "beeswarm", addYAxisTitle = TRUE) +
276277
scale_fill_wb_d(palette = "income") +

0 commit comments

Comments
 (0)