bradford-johnson / quarto-portfolio

[OLD SITE VERSION] Code and assets for my portfolio website
https://bradfordjohnson.github.io/quarto-portfolio/
0 stars 0 forks source link

TidyTuesday week 20 #70

Closed bradfordjohnson closed 1 year ago

bradfordjohnson commented 1 year ago
# Get the Data

# Read in with tidytuesdayR package 
# Install from CRAN via: install.packages("tidytuesdayR")
# This loads the readme and all the datasets for the week of interest

# Either ISO-8601 date or year/week works!

tuesdata <- tidytuesdayR::tt_load('2023-05-16')
tuesdata <- tidytuesdayR::tt_load(2023, week = 20)

tornados <- tornados

# Or read in the data manually

tornados <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-05-16/tornados.csv')

Data Dictionary

tornados.csv

variable class description
om integer Tornado number. Effectively an ID for this tornado in this year.
yr integer Year, 1950-2022.
mo integer Month, 1-12.
dy integer Day of the month, 1-31.
date date Date.
time time Time.
tz character Canonical tz database timezone.
datetime_utc datetime Date and time normalized to UTC.
st character Two-letter postal abbreviation for the state (DC = Washington, DC; PR = Puerto Rico; VI = Virgin Islands).
stf integer State FIPS (Federal Information Processing Standards) number.
mag integer Magnitude on the F scale (EF beginning in 2007). Some of these values are estimated (see fc).
inj integer Number of injuries. When summing for state totals, use sn == 1 (see below).
fat integer Number of fatalities. When summing for state totals, use sn == 1 (see below).
loss double Estimated property loss information in dollars. Prior to 1996, values were grouped into ranges. The reported number for such years is the maximum of its range.
slat double Starting latitude in decimal degrees.
slon double Starting longitude in decimal degrees.
elat double Ending latitude in decimal degrees.
elon double Ending longitude in decimal degrees.
len double Length in miles.
wid double Width in yards.
ns integer Number of states affected by this tornado. 1, 2, or 3.
sn integer State number for this row. 1 means the row contains the entire track information for this state, 0 means there is at least one more entry for this state for this tornado (om + yr).
f1 integer FIPS code for the 1st county.
f2 integer FIPS code for the 2nd county.
f3 integer FIPS code for the 3rd county.
f4 integer FIPS code for the 4th county.
fc logical Was the mag column estimated?
bradfordjohnson commented 1 year ago

Idea for using ggmagnify

image

bradfordjohnson commented 1 year ago

Other topics or themes

bradfordjohnson commented 1 year ago
pacman::p_load(tidyverse,
               ggmap)

tornados <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-05-16/tornados.csv')

tor_mag_5 <- tornados |>
  filter(mag == 5) |>
  mutate(post = case_when(
    yr >= 2000 ~ "Post-2000",
    yr < 2000 ~ "Pre-2000"
  ))

bbox <- c(bottom = 25.75, top = 49 , right = -67, left = -125)

usmap <- get_stamenmap(bbox = bbox, zoom = 6, maptype = 'toner-lite') 

ggmap(usmap) + 
  geom_density_2d_filled(data = tor_mag_5, 
                  mapping = aes(x = slon, y = slat), alpha = .5) +
  theme_void() +
  labs(title = "Where F5 Tornados Start")
bradfordjohnson commented 1 year ago

The visual I want

Make the starting point and ending points for tornados, and then have a line drawn between the two

bradfordjohnson commented 1 year ago

Visual is done, just need to update site