Description Usage Format Details References Examples
A dataset containing historical monthly snowfall records. Columns are in character because of T cell values. The user will want to determine what T means, replace it with an appropriate value, and convert the columns to numeric.
1 |
A data frame with 78 rows and 13 variables
SEASON. Year span for winter season
JUL. Snow fall in this month
AUG. Snow fall in this month
SEP. Snow fall in this month
OCT. Snow fall in this month
NOV. Snow fall in this month
DEC. Snow fall in this month
JAN. Snow fall in this month
FEB. Snow fall in this month
MAR. Snow fall in this month
APR. Snow fall in this month
MAY. Snow fall in this month
JUN. Snow fall in this month
https://www.weather.gov/buf/BuffaloSnow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## Not run:
library(tidyverse)
library(exampledata)
library(viridis)
bufsnow <- buffalo_snow %>%
gather(Month, Snow, - SEASON) %>%
extract(SEASON, c('Start'), '(\\d{4})-\\d{2}', remove = FALSE) %>%
filter(!is.na(Snow)) %>%
mutate(
Month = gsub('(^.)(.+$)', '\\U\\1\\L\\2', Month, perl = TRUE) %>%
factor(levels = month.abb),
Snow = replace_na(as.numeric(Snow), .01),
Start = as.integer(Start),
Year = case_when(as.integer(Month) %in% 1:6 ~ as.integer(Start + 1), TRUE ~ Start)
) %>%
rename(Season = SEASON) %>%
arrange(Season, Year, Month) %>%
select(Season, Year, Month, Snow)
bufsnow %>%
ggplot(aes(x = Month, y = Snow, color = as.factor(Year), group = Year)) +
geom_line() +
coord_polar()
bufsnow %>%
mutate(Month = factor(Month, levels = c(month.abb[c(7:12, 1:6)]))) %>%
ggplot(aes(x = Month, y = Season, fill= Snow)) +
geom_tile() +
scale_fill_viridis()
bufsnow %>%
group_by(Season) %>%
summarize(total = sum(Snow)) %>%
ggplot(aes(y=total, x=Season, group = 1)) +
geom_line(size = 1) +
geom_point() +
theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust =1))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.