── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks 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)library(sf)
Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
Rows: 450 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.
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()
states %>%inner_join(state_pregnancy) %>%ggplot() +geom_sf(aes(fill = RATE)) +coord_sf(datum =NA) +theme_minimal() +scale_fill_viridis_c(labels =label_comma()) +labs(title ="Teen Pregnancy in 2021")
Joining with `by = join_by(NAME)`
The map above displays the quantity of teen-aged pregnancies per state in 2021. From this map we can see that the Southeast region of the United States has the highest amount of teen pregnancies in 2021.
Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
Need '+proj=longlat +datum=WGS84'
The leaflet map above displays an interactive method to show the quantity of teen pregnancies per state in 2021. Furthermore, we see that Arkansas has the hgihest rate of teen pregnancies (26.5%), and following close behind is Mississippi (25.6%). The state with the lowest rate of teen pregnancies in 2021 was the state of New Hampshire with a rate of 5.4%.
Warning: One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
dat <- vroom(...)
problems(dat)
Rows: 921228 Columns: 30
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (18): location, county_name, subject_race, subject_sex, department_name...
dbl (5): raw_row_number, lat, lng, subject_age, vehicle_year
lgl (5): arrest_made, citation_issued, warning_issued, frisk_performed, se...
date (1): date
time (1): time
ℹ 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.
The dataset I’ve chosen is based out of the state of Montana. this dataset initially looked at traffic stops and the reasons the traffic stops occured. Based on the code above I’ve filtered the dataset to display the number of speeding incidents in the state of Montana.