library(tidyverse)
library(lubridate)
library(broom)
library(scales)
library(gganimate)
# Load and clean data
# This data comes from Dark Sky's API
weather_provo_raw <- read_csv("https://andhs.co/provoweather")
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) | |
treesize <- 10 | |
trunkheight <- 5 | |
trunkwidth <- 2.5 | |
tree <- | |
tibble( | |
x = rep(treesize:1, each = 2), |
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
## Code by Walker Harrison @walkwearscrocs | |
## From https://www.walker-harrison.com/posts/2021-02-13-visualizing-how-a-kernel-draws-a-smooth-line/ | |
library(tidyverse) | |
theme_set(theme_bw()) | |
set.seed(0) | |
n <- 100 | |
x <- runif(n, 0, 4*pi) |
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) | |
relig_income <- relig_income %>% | |
pivot_longer(!religion, names_to = "income", values_to = "count") | |
relig_income | |
relig_income %>% count(religion) | |
relig_income %>% |
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
# Adapted from https://stackoverflow.com/a/7267364/1036500 by Andrie de Vries | |
# This is it: theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) | |
library(ggplot2) | |
td <- expand.grid( | |
hjust=c(0, 0.5, 1), | |
vjust=c(0, 0.5, 1), | |
angle=c(0, 45, 90), |
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(dplyr, warn.conflicts = FALSE) | |
mtcars %>% | |
group_nest(cyl) %>% | |
mutate(model = purrr::map(data, ~ lm(mpg ~ wt, data = .))) %>% | |
mutate(result = purrr::map(model, ~ broom::tidy(.))) %>% | |
tidyr::unnest(result) | |
mtcars %>% | |
group_by(cyl) %>% |
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(dplyr) | |
library(slider) | |
library(lubridate) | |
library(tsibbledata) | |
# Google, Apple, Facebook, Amazon stock | |
gafa_stock <- as_tibble(gafa_stock) | |
gafa_stock <- select(gafa_stock, Symbol, Date, Close, Volume) | |
head(gafa_stock, 2) |
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(ggridges) | |
library(patchwork) | |
p1 <- ggplot(mpg, aes(x = cty, y = hwy)) + | |
geom_point() + | |
geom_smooth() + | |
labs(title = "1: geom_point() + geom_smooth()") + | |
theme(plot.title = element_text(face = "bold")) |
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(easyuse) # devtools::install_github("perlatex/easyuse") | |
library(tidyverse) | |
library(showtext) | |
showtext_auto() | |
data(ChineseTones) | |
d <- ChineseTones | |
d |
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(patchwork) | |
dat_wide <- tibble( | |
x = 1:3, | |
top = c(4.5, 4, 5.5), | |
middle = c(4, 4.75, 5), | |
bottom = c(3.5, 3.75, 4.5) | |
) |
NewerOlder