Skip to content

Instantly share code, notes, and snippets.

View ivelasq's full-sized avatar

Isabella Velásquez ivelasq

View GitHub Profile
@ivelasq
ivelasq / student_save.R
Created October 30, 2021 02:00
Save student name as variable in RStudio Cloud
library(tidyverse)
student_name <-
rstudioapi::showPrompt(title = "Name", message = "What's your first name?")
dat %>%
write_csv(here::here("submit", str_glue("final_{student_name}.csv")))
@ivelasq
ivelasq / gt_saves.R
Last active October 29, 2021 01:07
Separately saving multiple gt tables
library(tidyverse)
library(gt)
dat <-
tibble::tribble( ~ C1, ~ C2,
19L, 73L,
92L, 83L,
35L, 70L,
40L, 12L) %>%
dplyr::mutate(c1_parity = case_when(C1 %% 2 == 0 ~ "Even",
@ivelasq
ivelasq / map.R
Last active October 5, 2021 04:27
Choropleth map with urbnmapr
library(tidyverse)
# devtools::install_github("UrbanInstitute/urbnmapr")
library(urbnmapr)
# devtools::install_github("UrbanInstitute/urbnthemes")
library(urbnthemes)
library(janitor)
set_urbn_defaults(style = "map")
nurses <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-10-05/nurses.csv') %>%
@ivelasq
ivelasq / k12_enrollment_plot.R
Last active March 25, 2021 16:58
K-12 Enrollment Plot
# Enrollment Demographics Stacked Bar Plot
# Libraries ---------------------------------------------------------------
library(tidyverse)
library(geofacet)
library(showtext)
library(cowplot)
font_add_google("Noto Sans", "noto-sans")
@ivelasq
ivelasq / 2021-01-26_tidy_tuesday.R
Last active January 29, 2021 01:01
2021-01-26 Tidy Tuesday
library(tidyverse)
library(ggthemr)
ggthemr("dust")
tuesdata <- tidytuesdayR::tt_load('2021-01-26')
plastics <- tuesdata$plastics
plastics_group <-
plastics %>%
@ivelasq
ivelasq / plots.R
Created January 11, 2021 05:17
Repeating Plots by Group
library(tidyverse)
relig_income <- relig_income %>%
pivot_longer(!religion, names_to = "income", values_to = "count")
relig_plot <- function(.x) {
relig_income %>%
filter(religion == .x) %>% {
ggplot(., aes(x = income, y = count, fill = religion)) +
geom_bar(stat = "identity", position = "dodge")
@ivelasq
ivelasq / ssbm.R
Last active January 3, 2021 15:24
Age Distribution of the Top 100 Super Smash Bros. Melee Players (2019)
##########################################################
# Get Ages of Top 100 Super Smash Brothers Melee Players #
##########################################################
# Tutorial ----------------------------------------------------------------
# https://www.r-bloggers.com/2020/05/intro-to-polite-web-scraping-of-soccer-data-with-r/
# Library -----------------------------------------------------------------
@ivelasq
ivelasq / trail.R
Created December 7, 2020 01:13
Mapping Coordinates on a Trail
# Libraries
library(tidyverse)
library(sf)
library(ggmap)
# Open files
f <-
here::here("data", "raw", "GRSM_TRAILS-shp", "GRSM_TRAILS.shp")
@ivelasq
ivelasq / aoc_day03.R
Last active December 4, 2020 04:12
Advent of Code 2020 - Day 03
# Advent of Code - Day 03
# Data --------------------------------------------------------------------
dat <-
as.matrix(read.fwf(
here::here("day_03", "trees.txt"),
widths = rep(1, 31),
comment.char = ""
))
@ivelasq
ivelasq / aoc_day02.R
Last active December 3, 2020 02:16
Advent of Code 2020 - Day 02
library(tidyverse)
# Input -------------------------------------------------------------------
input <-
tibble::tribble(
~ `passwords`,
"13-16 k:kkkkkgmkbvkkrskhd",
"5-6 p: qpppvzp",
"3-4 p: psppxhlfpvkh",