Description Usage Arguments Examples
View source: R/h_geom_prop_in_ts.R
Tiles the are filled according to proportion where total in x is denominator
1 2 3 4 5 6 7 8 9 |
... |
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 | # do it without function
library(tidyverse)
gapminder::gapminder %>%
mutate(gdp = gdpPercap * pop) ->
my_gapminder
my_gapminder %>%
group_by(year, continent) %>%
summarise(gdp = sum(gdp)) %>%
mutate(prop_gdp = gdp/sum(gdp)) %>%
ggplot() +
aes(x = year) +
aes(y = continent) +
geom_tile() +
aes(fill = prop_gdp) +
scale_fill_viridis_c()
# the function and proto
"StatPropovertime"
"StatPropovertimetext"
# use function
library(ggplot2)
library(magrittr)
my_gapminder %>%
ggplot() +
aes(x = year) +
aes(y = continent) +
h_geom_tile_prop_over_time() +
aes(fill = gdp) +
scale_fill_viridis_c()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.