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) | |
# https://www.produce.co.nz/seasonality-chart/ | |
fruits <- tibble::tribble( | |
~ fruit, ~start, ~ end, | |
"Blueberry", "October", "April", |
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', |
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 |> |
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; |
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} |
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') |
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 |
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 |
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( |
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) |
NewerOlder