── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks plotly::filter(), stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)library(scales)
Attaching package: 'scales'
The following object is masked from 'package:purrr':
discard
The following object is masked from 'package:readr':
col_factor
library(tidycensus) # gets census data that we can use to create mapslibrary(sf) # helper package for mapping
Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(leaflet) # interactive mapping packagelibrary(usdata) # this package has a conversion utility for state abbreviations to full names
states <-get_acs(geography ="state", # gets state by state datavariables ="B01003_001", # this is state populationgeometry =TRUE, # gets geometry (the maps)shift_geo = T) # shifts Hawaii and Alaska
Getting data from the 2018-2022 5-year ACS
Warning: The `shift_geo` argument is deprecated and will be removed in a future
release. We recommend using `tigris::shift_geometry()` instead.
Using feature geometry obtained from the albersusa package
Please note: Alaska and Hawaii are being shifted and are not to scale.
old-style crs object detected; please recreate object with a recent sf::st_crs()
life_expectancy <-read_csv("life_expectancy.csv")
Rows: 150 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): STATE, URL
dbl (2): YEAR, RATE
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
states_leaflet <-get_acs(geography ="state", # gets state by state datavariables ="B01003_001", # this is state incomegeometry =TRUE, # gets geometry (the maps)shift_geo = F) # we're not shifting Hawaii and Alaska!
Getting data from the 2018-2022 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Rows: 9570 Columns: 19
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (12): threat_type, flee_status, armed_with, city, county, state, locati...
dbl (4): id, latitude, longitude, age
lgl (2): was_mental_illness_related, body_camera
date (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.