Skip to content

Instantly share code, notes, and snippets.

@AlbertRapp
AlbertRapp / twitter_tracking.R
Last active May 12, 2022 23:49
Get Dataviz from Twitter into your note-taking system using R
### Change these parts here ----------------------------------------------------
# Set to your working directory where there is a template.md file
setwd(here::here())
# Locations
vault_location <- stop('Add Vault Location') # Location of markdown files
attachments_dir <- stop('Add Vault Subdirectory Location') # subdirectory of vault_location for png-files
imap_mail <- stop('Set imap mail client') # mail client
library(tidyverse)
dat <- mpg %>%
mutate(
custom_color = if_else(
year == 2008 & manufacturer == 'audi',
'dodgerblue4',
'grey80'
)
)
@AlbertRapp
AlbertRapp / polar_coord_legend.R
Created June 7, 2022 14:54
polar_coord_legend.R
camcorder::gg_record(
dir = 'img',
height = 16,
width = 16,
units = 'cm'
)
library(tidyverse)
library(ggforce)
dat <- tibble(
@AlbertRapp
AlbertRapp / street_map_game_mechanics.qmd
Created June 19, 2022 14:59
Testing out the mechanics for a shiny web app/game with maps and street names
---
output: html_document
editor_options:
chunk_output_type: console
---
## Load Packages
```{r}
setwd(here::here('streep_map_game/'))
@AlbertRapp
AlbertRapp / responsive_tabsets.qmd
Created July 25, 2022 13:17
Responsive tabsets
```{r}
#| message: false
library(tidyverse)
```
::: panel-tabset
## Responsive
@AlbertRapp
AlbertRapp / data_viewer_app.R
Created August 29, 2022 14:29
This is a non-modularized Shiny app to explore different data sets.
setwd(here::here('shiny_modules'))
library(shiny)
library(ggplot2)
ui <- fluidPage(
theme = bslib::bs_theme(
# Colors (background, foreground, primary)
bg = 'white',
fg = '#06436e',
primary = colorspace::lighten('#06436e', 0.3),
@AlbertRapp
AlbertRapp / data_viewer_app_modularized.R
Created August 29, 2022 15:05
This is a non-modularized Shiny app to explore different data sets.
setwd(here::here('shiny_modules'))
library(shiny)
library(ggplot2)
data_viewer_UI <- function(id, my_data_set) {
ns <- NS(id)
tagList(
sidebarLayout(
sidebarPanel(
@AlbertRapp
AlbertRapp / usa_religions.qmd
Created September 10, 2022 20:28
Two sample plots for pie charts with lots of slices
---
output: html_document
editor_options:
chunk_output_type: console
---
```{r}
setwd(here::here('religions_usa'))
library(tidyverse)
@AlbertRapp
AlbertRapp / shinyjs_toggle.R
Created September 22, 2022 18:38
shinyjs toggle
library(shiny)
library(ggplot2)
library(dplyr)
ui <- fluidPage(
shinyjs::useShinyjs(),
theme = bslib::bs_theme(
# Colors (background, foreground, primary)
bg = 'white',
fg = '#06436e',
@AlbertRapp
AlbertRapp / linear_gradient_rect.R
Created October 4, 2022 19:53
Hopefully helpful function for Tanya's ggplot phone
library(ggplot2)
library(grid)
library(ggpp)
rect_gr <- grid.rect(
gp = gpar(
col = NA,
fill = linearGradient(
colours = thematic::okabe_ito(2),
# Units is npc (so values between 0 and 1)
x1 = 1, y1 = 1,