View split_stacked_bar_charts_YT.R
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) | |
mpg_2008 <- mpg |> | |
filter( | |
year == 2008, | |
!(class %in% c('2seater', 'minivan')) | |
) |> | |
mutate( | |
class = case_when( | |
class %in% c('compact', 'subcompact') ~ '(Sub-)Compact', |
View maps_instead_of_for_loops.R
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) | |
dat <- gapminder::gapminder | |
####### For loop approach | |
slopes <- numeric(5) | |
names(slopes) <- unique(dat$continent) | |
for (selected_continent in unique(dat$continent)) { | |
filtered_data <- dat |> |
View dot-columns-gt.R
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) | |
library(gt) | |
circle <- '<span style=" | |
display: inline-block; | |
background-color: pink; | |
width: 1cm; | |
height: 1cm; | |
border-radius: 100%; | |
border: black 1px solid; |
View perfect_bar_chart.qmd
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(tidyverse) | |
manufacturers <- mpg |> | |
mutate(manufacturer = str_to_title(manufacturer)) | |
``` | |
```{r} |
View interactive_gt.R
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(gt) | |
gt::towny |> # new data set in {gt} 0.9.0 | |
dplyr::select(name, land_area_km2) |> | |
gt() |> | |
cols_label(name = 'Name', land_area_km2 = 'Area (sq.km)') |> | |
opt_interactive( | |
use_search = TRUE, use_filters = TRUE, | |
use_compact_mode = TRUE, page_size_default = 5 | |
) |> | |
tab_options(table.width = '500px', container.width = '500px') |
View 01_gt_gtExtras_incorporated.R
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(gt) | |
library(tidyverse) | |
tribble( | |
~flag, ~country, ~population, | |
'DE', 'Germany', 84270625, | |
'US', 'United States', 333287557, | |
'IE', 'Italy', 58853482, | |
'GY', 'Guyana', 795408, | |
'NO', 'Norway', 5488984, | |
'GH', 'Ghana', 32103042 |
View shiny-styling-thread.qmd
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
## No styling app | |
```{r} | |
setwd(here::here()) | |
library(shiny) | |
library(tidyverse) | |
penguins <- palmerpenguins::penguins |> filter(!is.na(sex)) | |
# Define UI |
View shiny_modules_60_seconds.R
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
setwd(here::here('02_shiny_modules')) | |
library(shiny) | |
library(ggplot2) | |
ui <- fluidPage( | |
theme = bslib::bs_theme(bootswatch = 'flatly'), | |
tabsetPanel( | |
tabPanel("Penguins", { | |
sidebarLayout( |
View icon_dice.qmd
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(tidyverse) | |
library(showtext) | |
library(ggtext) | |
font_add('fa-solid', '00_fonts/Font Awesome 6 Free-Solid-900.otf') | |
showtext_auto() | |
showtext_opts(dpi = 300) |
View position_dodge.R
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' | |
) |
NewerOlder