Skip to content

Instantly share code, notes, and snippets.

View dgkeyes's full-sized avatar

David Keyes dgkeyes

View GitHub Profile
## %######################################################%##
# #
#### Letter case - your turn ####
# #
## %######################################################%##
# Import the Marine Protected Areas dataset (MPAS-your.csv)
# Summarize the number of Marine Protected Areas by country (Country full).
third_grade_math_proficiency_18_19 <- read_excel(path = here("data", "math-scores-18-19.xlsx")) %>%
filter(student_group == "Total Population (All Students)") %>%
filter(grade_level == "Grade 3") %>%
select(school_id, contains("number")) %>%
pivot_longer(cols = contains("number"),
names_to = "proficiency_level",
values_to = "number_proficient") %>%
mutate(number_proficient = na_if(number_proficient, "*")) %>%
mutate(number_proficient = na_if(number_proficient, "--")) %>%
mutate(number_proficient = as.numeric(number_proficient)) %>%
Hi Expensify,
Don’t hire me. I don’t have the background you’re expecting. At all.
I’ve never done “customer service.” I’ve never worked in a business. I’ve never used Expensify.
My career stops have included: second grade teacher, PhD in anthropology, college professor, and researcher at a foundation.
So I’m seriously probably the worst candidate you could ever imagine.
iris %>%
group_by(Species) %>%
summarize(mean_petal_width = mean(Petal.Width)) %>%
ungroup() %>%
ggplot(aes(Species, mean_petal_width,
fill = Species)) +
geom_col(show.legend = FALSE) +
theme_ipsum() +
scale_fill_manual(values = c("setosa" = "lightgray",
"versicolor" = "lightgray",
iris %>%
group_by(Species) %>%
summarize(mean_petal_width = mean(Petal.Width)) %>%
ungroup() %>%
ggplot(aes(Species, mean_petal_width)) +
geom_col() +
theme_ipsum() +
labs(x = NULL,
y = NULL,
title = "Average petal width of irises by species")
Name Upward Mobility: Percent of People from Low-Income Families (25th Percentile) who Grow up to be High Income (Top 20%)*
Baker County, OR 12.00%
Benton County, OR 13.41%
Clackamas County, OR 13.21%
Clatsop County, OR 12.26%
Columbia County, OR 11.11%
Coos County, OR 9.70%
Crook County, OR 10.75%
Curry County, OR 10.36%
Deschutes County, OR 11.08%
outputs <- read_excel(path = "data-raw/outputs_profservcices.xlsx") %>%
mutate(hours_counted = case_when(
activity == "Output" ~ hours,
activity == "A la Carte Referral" & prosper_approved == "Yes" ~ hours,
activity == "SBLC Referral" & accepted == "Yes" ~ hours,
activity == "MFS Referral" & accepted == "Yes" ~ hours,
activity == "MarketLink Referral" & accepted == "Yes" ~ hours
)) %>%
mutate(activity_categorized = case_when(
activity == "Output" ~ "Output",
library(tidyverse)
diamonds_summary <- diamonds %>%
count(cut) %>%
mutate(cut = factor(cut, levels = c("Fair",
"Good",
"Very Good",
"Premium",
"Ideal"))) %>%
mutate(cut = fct_rev(cut))
@dgkeyes
dgkeyes / dk_summarize_with_totals
Created August 16, 2019 19:57
summarize with totals
dk_summarize_with_totals <- function(.data, group_by_var, mean_var){
groups_summary <- .data %>%
dplyr::group_by({{ group_by_var }}) %>%
dplyr::summarize(mean = mean({{ mean_var }})) %>%
dplyr::rename("group" = {{ group_by_var }} )
overall_summary <-.data %>%
dplyr::summarize(mean = mean({{ mean_var }})) %>%
dplyr::mutate(group = "Total")
@dgkeyes
dgkeyes / ggplot-without-arguments.R
Created May 8, 2019 16:22
ggplot without arguments
ggplot(sleep_by_gender,
aes(gender,
avg_sleep,
fill = gender)) +
geom_col()