How could the authors of the 2016 WHO TB report have created the following plots? Assume that each plot is based on one or several suitably crafted dataset(s), i.e., that the data has been transformed in advance to support this particular plot. Answer the following questions for each plot:
Recreate the following plots by filling in the dots in the corresponding code snippets. Use the high_impact_stats
dataset from the gfdata
package. What is the purpose of the predefined scale_...()
and theme()
calls?
library(gfdata)
ggplot(
data = ...,
mapping = aes(
x = ordered(...),
y = ...
)
) +
geom_...() +
scale_y_continuous(labels = scales::percent, limits = c(0, NA)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
## Warning: Removed 39 rows containing non-finite values (stat_boxplot).
library(gfdata)
ggplot(...) +
geom_...(
...,
fill = "grey"
) +
geom_line(
...,
color = "green"
) +
facet_wrap(~..., scales = ..., ncol = 3) +
scale_y_continuous(limits = c(0, NA))
high_impact_stats_tb_long <-
high_impact_stats %>%
select(
iso3, country, five_regions, year,
tb_new_cases_number, tb_deaths_number
) %>%
gather(indicator, number, starts_with("tb_"))
ggplot(
data = high_impact_stats_tb_long,
mapping = aes()
) +
geom_...() +
facet_...(...) +
scale_y_continuous(limits = c(0, NA))
## Warning: Removed 2 rows containing missing values (geom_path).
Copyright © 2017 Kirill Müller. Licensed under CC BY-NC 4.0.