This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
tooth_data <- ToothGrowth |> | |
as_tibble() |> | |
mutate(dose = factor(dose)) | |
tooth_data_relabeled <- tooth_data |> | |
mutate( | |
supp = if_else( | |
supp == 'VC', 'Vitamin C supplement', 'Orange Juice' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Renaming long names | |
Load `tidyverse` and data from TidyTuesday. | |
```{r} | |
library(tidyverse) | |
big_tech_companies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_companies.csv') | |
big_tech_companies | |
# # A tibble: 14 × 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
big_tech_companies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_companies.csv') | |
big_tech_companies | |
# # A tibble: 14 × 2 | |
# stock_symbol company | |
# <chr> <chr> | |
# 1 AAPL Apple Inc. | |
# 2 ADBE Adobe Inc. | |
# 3 AMZN Amazon.com, Inc. | |
# 4 CRM Salesforce, Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r} | |
library(ggiraph) | |
library(tidyverse) | |
library(patchwork) | |
library(shiny) | |
library(gt) | |
``` | |
## Prep work for the Shiny app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r} | |
library(ggiraph) | |
library(tidyverse) | |
library(patchwork) | |
library(shiny) | |
library(gt) | |
``` | |
## Prep work for the Shiny apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r} | |
setwd(here::here('democracy_index')) | |
library(tidyverse) | |
library(shadowtext) | |
library(ggiraph) | |
library(ggtext) | |
library(gdtools) | |
register_gfont("Roboto Mono") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(ggiraph) | |
dat <- gapminder::gapminder |> | |
janitor::clean_names() |> | |
mutate( | |
# ID that is shared for boxplots (this one uses factors, i.e. numbers, as ID instead of continents) | |
id = as.numeric(continent), | |
continent = forcats::fct_reorder(continent, life_exp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(ggplot2) | |
library(ggiraph) | |
# STEP 0: Compute Data and generate color palette | |
mean_life_exps <- gapminder::gapminder |> | |
janitor::clean_names() |> | |
group_by(continent, year) |> | |
summarise(mean_life_exp = mean(life_exp)) | |
color_palette <- thematic::okabe_ito(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(ggtext) | |
library(showtext) | |
font_add_google('Fira Sans', 'firasans') | |
font_add_google('Roboto Mono', 'robotomono') | |
font_add('fa-brands', '00_fonts/Font Awesome 6 Brands-Regular-400.otf') | |
showtext_auto() |