library(tidyverse)
library(tidyr)
#setwd("C:/Users/rsaidi/Dropbox/Rachel/MontColl/Datasets/Datasets")
cities500 <- read_csv("500CitiesLocalHealthIndicators.cdc.csv")
data(cities500)Healthy Cities GIS Assignment
Load the libraries and set the working directory
The GeoLocation variable has (lat, long) format
Split GeoLocation (lat, long) into two columns: lat and long
?str_replace_all
latlong <- cities500|>
mutate(GeoLocation = str_replace_all(GeoLocation, "[()]", ""))|>
separate(GeoLocation, into = c("lat", "long"), sep = ",", convert = TRUE)
head(latlong)# A tibble: 6 × 25
Year StateAbbr StateDesc CityName GeographicLevel DataSource Category
<dbl> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 CA California Hawthorne Census Tract BRFSS Health Outcom…
2 2017 CA California Hawthorne City BRFSS Unhealthy Beh…
3 2017 CA California Hayward City BRFSS Health Outcom…
4 2017 CA California Hayward City BRFSS Unhealthy Beh…
5 2017 CA California Hemet City BRFSS Prevention
6 2017 CA California Indio Census Tract BRFSS Health Outcom…
# ℹ 18 more variables: UniqueID <chr>, Measure <chr>, Data_Value_Unit <chr>,
# DataValueTypeID <chr>, Data_Value_Type <chr>, Data_Value <dbl>,
# Low_Confidence_Limit <dbl>, High_Confidence_Limit <dbl>,
# Data_Value_Footnote_Symbol <chr>, Data_Value_Footnote <chr>,
# PopulationCount <dbl>, lat <dbl>, long <dbl>, CategoryID <chr>,
# MeasureId <chr>, CityFIPS <dbl>, TractFIPS <dbl>, Short_Question_Text <chr>
Filter the dataset
Remove the StateDesc that includes the United Sates, select Prevention as the category (of interest), filter for only measuring crude prevalence and select only 2017.
latlong_clean <- latlong |>
filter(StateDesc != "United States") |>
filter(Category == "Prevention") |>
filter(Data_Value_Type == "Crude prevalence") |>
filter(Year == 2017)
head(latlong_clean)# A tibble: 6 × 25
Year StateAbbr StateDesc CityName GeographicLevel DataSource Category
<dbl> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 AL Alabama Montgomery City BRFSS Prevention
2 2017 CA California Concord City BRFSS Prevention
3 2017 CA California Concord City BRFSS Prevention
4 2017 CA California Fontana City BRFSS Prevention
5 2017 CA California Richmond Census Tract BRFSS Prevention
6 2017 FL Florida Davie Census Tract BRFSS Prevention
# ℹ 18 more variables: UniqueID <chr>, Measure <chr>, Data_Value_Unit <chr>,
# DataValueTypeID <chr>, Data_Value_Type <chr>, Data_Value <dbl>,
# Low_Confidence_Limit <dbl>, High_Confidence_Limit <dbl>,
# Data_Value_Footnote_Symbol <chr>, Data_Value_Footnote <chr>,
# PopulationCount <dbl>, lat <dbl>, long <dbl>, CategoryID <chr>,
# MeasureId <chr>, CityFIPS <dbl>, TractFIPS <dbl>, Short_Question_Text <chr>
What variables are included? (can any of them be removed?)
names(latlong_clean) [1] "Year" "StateAbbr"
[3] "StateDesc" "CityName"
[5] "GeographicLevel" "DataSource"
[7] "Category" "UniqueID"
[9] "Measure" "Data_Value_Unit"
[11] "DataValueTypeID" "Data_Value_Type"
[13] "Data_Value" "Low_Confidence_Limit"
[15] "High_Confidence_Limit" "Data_Value_Footnote_Symbol"
[17] "Data_Value_Footnote" "PopulationCount"
[19] "lat" "long"
[21] "CategoryID" "MeasureId"
[23] "CityFIPS" "TractFIPS"
[25] "Short_Question_Text"
Remove the variables that will not be used in the assignment
prevention <- latlong_clean |>
select(-DataSource,-Data_Value_Unit, -DataValueTypeID, -Low_Confidence_Limit, -High_Confidence_Limit, -Data_Value_Footnote_Symbol, -Data_Value_Footnote)
head(prevention)# A tibble: 6 × 18
Year StateAbbr StateDesc CityName GeographicLevel Category UniqueID Measure
<dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 AL Alabama Montgome… City Prevent… 151000 Choles…
2 2017 CA California Concord City Prevent… 616000 Visits…
3 2017 CA California Concord City Prevent… 616000 Choles…
4 2017 CA California Fontana City Prevent… 624680 Visits…
5 2017 CA California Richmond Census Tract Prevent… 0660620… Choles…
6 2017 FL Florida Davie Census Tract Prevent… 1216475… Choles…
# ℹ 10 more variables: Data_Value_Type <chr>, Data_Value <dbl>,
# PopulationCount <dbl>, lat <dbl>, long <dbl>, CategoryID <chr>,
# MeasureId <chr>, CityFIPS <dbl>, TractFIPS <dbl>, Short_Question_Text <chr>
md <- prevention |>
filter(StateAbbr=="MD")
head(md)# A tibble: 6 × 18
Year StateAbbr StateDesc CityName GeographicLevel Category UniqueID Measure
<dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Chole…
2 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
3 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
4 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Curre…
5 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Curre…
6 2017 MD Maryland Baltimore Census Tract Preventi… 2404000… "Visit…
# ℹ 10 more variables: Data_Value_Type <chr>, Data_Value <dbl>,
# PopulationCount <dbl>, lat <dbl>, long <dbl>, CategoryID <chr>,
# MeasureId <chr>, CityFIPS <dbl>, TractFIPS <dbl>, Short_Question_Text <chr>
unique(md$CityName)[1] "Baltimore"
The new dataset “Prevention” is a manageable dataset now.
For your assignment, work with a cleaned dataset.
1. Once you run the above code, filter this dataset one more time for any particular subset with no more than 900 observations.
library(tidyverse)
library(tidyr)Load data set and filter the variables based on the desired content
We are looking at specific locations, in this case I will be comparing the US-Mexico border and the US-Canada border.
border_df <- read_csv("Border_Crossing_Entry_Data.csv")Rows: 395638 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (7): Port Name, State, Port Code, Border, Date, Measure, Point
dbl (3): Value, Latitude, Longitude
ℹ 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.
us_cana <- border_df |>
filter(Border=="US-Canada Border") |>
filter(Measure == "Trucks")|>
group_by(`Port Name`)|>
mutate(total_Value = sum(Value),
mean_Value = mean(Value))
unique(us_cana$State) [1] "Minnesota" "Montana" "Maine" "North Dakota" "Washington"
[6] "Michigan" "Vermont" "New York" "Alaska" "Idaho"
us_mex <- border_df |>
filter(Border=="US-Mexico Border")|>
filter(Measure == "Trucks")|>
group_by(`Port Name`)|>
mutate(total_Value = sum(Value),
mean_Value = mean(Value))
unique(us_mex$State)[1] "Texas" "New Mexico" "Arizona" "California"
Unfortunately, variable “Date” is classified as a character and not a numeric. So I created a subset of the desired characters, Jan 2023-Dec 2023,” and then converted the characters to a “date.”
class(border_df$Date)[1] "character"
us_mex_2023 <- subset(us_mex, Date %in% c("Jan 2023", "Feb 2023", "Mar 2023", "Apr 2023", "May 2023", "Jun 2023", "Jul 2023", "Aug 2023" , "Sept 2023", "Oct 2023", "Nov 2023", "Dec 2023"))
us_mex_2023$Date <- as.Date(paste("01", us_mex_2023$Date), format = "%d %B %Y")
us_mex_2023$Date [1] "2023-12-01" "2023-11-01" "2023-08-01" "2023-02-01" "2023-01-01"
[6] "2023-05-01" "2023-03-01" "2023-06-01" "2023-02-01" "2023-06-01"
[11] "2023-03-01" "2023-01-01" "2023-05-01" "2023-02-01" "2023-08-01"
[16] "2023-01-01" "2023-04-01" "2023-01-01" "2023-11-01" "2023-07-01"
[21] "2023-01-01" "2023-12-01" "2023-01-01" "2023-07-01" "2023-05-01"
[26] "2023-05-01" "2023-05-01" "2023-02-01" "2023-10-01" "2023-03-01"
[31] "2023-12-01" "2023-05-01" "2023-08-01" "2023-12-01" "2023-11-01"
[36] "2023-02-01" "2023-12-01" "2023-10-01" "2023-10-01" "2023-05-01"
[41] "2023-06-01" "2023-06-01" "2023-06-01" "2023-03-01" "2023-05-01"
[46] "2023-12-01" "2023-08-01" "2023-06-01" "2023-05-01" "2023-06-01"
[51] "2023-11-01" "2023-06-01" "2023-06-01" "2023-07-01" "2023-06-01"
[56] "2023-03-01" "2023-04-01" "2023-08-01" "2023-12-01" "2023-08-01"
[61] "2023-02-01" "2023-10-01" "2023-04-01" "2023-11-01" "2023-03-01"
[66] "2023-11-01" "2023-10-01" "2023-10-01" "2023-01-01" "2023-08-01"
[71] "2023-08-01" "2023-10-01" "2023-10-01" "2023-06-01" "2023-04-01"
[76] "2023-01-01" "2023-04-01" "2023-05-01" "2023-03-01" "2023-05-01"
[81] "2023-02-01" "2023-11-01" "2023-03-01" "2023-11-01" "2023-11-01"
[86] "2023-11-01" "2023-12-01" "2023-04-01" "2023-10-01" "2023-07-01"
[91] "2023-12-01" "2023-01-01" "2023-01-01" "2023-03-01" "2023-02-01"
[96] "2023-12-01" "2023-03-01" "2023-10-01" "2023-03-01" "2023-02-01"
[101] "2023-10-01" "2023-03-01" "2023-03-01" "2023-03-01" "2023-04-01"
[106] "2023-11-01" "2023-08-01" "2023-07-01" "2023-07-01" "2023-01-01"
[111] "2023-03-01" "2023-03-01" "2023-02-01" "2023-12-01" "2023-10-01"
[116] "2023-06-01" "2023-11-01" "2023-11-01" "2023-05-01" "2023-02-01"
[121] "2023-10-01" "2023-02-01" "2023-04-01" "2023-05-01" "2023-02-01"
[126] "2023-06-01" "2023-12-01" "2023-04-01" "2023-05-01" "2023-07-01"
[131] "2023-06-01" "2023-11-01" "2023-10-01" "2023-07-01" "2023-01-01"
[136] "2023-04-01" "2023-06-01" "2023-07-01" "2023-04-01" "2023-08-01"
[141] "2023-01-01" "2023-04-01" "2023-12-01" "2023-04-01" "2023-07-01"
[146] "2023-01-01" "2023-01-01" "2023-07-01" "2023-11-01" "2023-10-01"
[151] "2023-08-01" "2023-02-01" "2023-10-01" "2023-08-01" "2023-07-01"
[156] "2023-11-01" "2023-12-01" "2023-01-01" "2023-12-01" "2023-08-01"
[161] "2023-04-01" "2023-05-01" "2023-06-01" "2023-01-01" "2023-03-01"
[166] "2023-04-01" "2023-05-01" "2023-02-01" "2023-04-01" "2023-07-01"
[171] "2023-07-01" "2023-02-01" "2023-08-01" "2023-02-01" "2023-12-01"
[176] "2023-11-01" "2023-01-01" "2023-01-01" "2023-04-01" "2023-05-01"
[181] "2023-08-01" "2023-05-01" "2023-10-01" "2023-04-01" "2023-07-01"
[186] "2023-06-01" "2023-04-01" "2023-08-01" "2023-11-01" "2023-10-01"
[191] "2023-08-01" "2023-10-01" "2023-10-01" "2023-06-01" "2023-11-01"
[196] "2023-06-01" "2023-03-01" "2023-07-01" "2023-11-01" "2023-03-01"
[201] "2023-08-01" "2023-12-01" "2023-02-01" "2023-01-01" "2023-12-01"
[206] "2023-02-01" "2023-12-01" "2023-12-01" "2023-12-01" "2023-07-01"
[211] "2023-01-01" "2023-08-01" "2023-07-01" "2023-08-01" "2023-07-01"
[216] "2023-11-01" "2023-05-01" "2023-06-01" "2023-07-01" "2023-02-01"
[221] "2023-08-01" "2023-02-01" "2023-06-01" "2023-05-01" "2023-12-01"
[226] "2023-08-01" "2023-10-01" "2023-05-01" "2023-11-01" "2023-03-01"
[231] "2023-04-01" "2023-04-01" "2023-10-01" "2023-03-01" "2023-07-01"
us_cana_2023 <- subset(us_cana, Date %in% c("Jan 2023", "Feb 2023", "Mar 2023", "Apr 2023", "May 2023", "Jun 2023", "Jul 2023", "Aug 2023" , "Sept 2023", "Oct 2023", "Nov 2023", "Dec 2023"))
us_cana_2023$Date <- as.Date(paste("01", us_cana_2023$Date), format = "%d %B %Y")
us_cana_2023$Date [1] "2023-08-01" "2023-08-01" "2023-03-01" "2023-02-01" "2023-01-01"
[6] "2023-07-01" "2023-07-01" "2023-11-01" "2023-11-01" "2023-10-01"
[11] "2023-04-01" "2023-03-01" "2023-10-01" "2023-08-01" "2023-07-01"
[16] "2023-04-01" "2023-05-01" "2023-04-01" "2023-04-01" "2023-08-01"
[21] "2023-07-01" "2023-05-01" "2023-01-01" "2023-11-01" "2023-02-01"
[26] "2023-02-01" "2023-11-01" "2023-02-01" "2023-06-01" "2023-12-01"
[31] "2023-07-01" "2023-01-01" "2023-08-01" "2023-10-01" "2023-05-01"
[36] "2023-04-01" "2023-12-01" "2023-02-01" "2023-01-01" "2023-10-01"
[41] "2023-06-01" "2023-12-01" "2023-05-01" "2023-06-01" "2023-08-01"
[46] "2023-11-01" "2023-05-01" "2023-05-01" "2023-11-01" "2023-01-01"
[51] "2023-08-01" "2023-01-01" "2023-04-01" "2023-10-01" "2023-07-01"
[56] "2023-03-01" "2023-01-01" "2023-12-01" "2023-07-01" "2023-05-01"
[61] "2023-08-01" "2023-03-01" "2023-04-01" "2023-05-01" "2023-08-01"
[66] "2023-07-01" "2023-05-01" "2023-07-01" "2023-04-01" "2023-08-01"
[71] "2023-10-01" "2023-10-01" "2023-08-01" "2023-06-01" "2023-10-01"
[76] "2023-05-01" "2023-12-01" "2023-03-01" "2023-02-01" "2023-08-01"
[81] "2023-02-01" "2023-03-01" "2023-07-01" "2023-08-01" "2023-06-01"
[86] "2023-11-01" "2023-08-01" "2023-03-01" "2023-10-01" "2023-11-01"
[91] "2023-12-01" "2023-06-01" "2023-11-01" "2023-06-01" "2023-11-01"
[96] "2023-04-01" "2023-05-01" "2023-03-01" "2023-10-01" "2023-06-01"
[101] "2023-07-01" "2023-01-01" "2023-10-01" "2023-02-01" "2023-05-01"
[106] "2023-06-01" "2023-01-01" "2023-07-01" "2023-07-01" "2023-10-01"
[111] "2023-04-01" "2023-10-01" "2023-01-01" "2023-03-01" "2023-08-01"
[116] "2023-08-01" "2023-01-01" "2023-03-01" "2023-04-01" "2023-10-01"
[121] "2023-08-01" "2023-03-01" "2023-08-01" "2023-06-01" "2023-12-01"
[126] "2023-11-01" "2023-05-01" "2023-05-01" "2023-03-01" "2023-10-01"
[131] "2023-03-01" "2023-06-01" "2023-12-01" "2023-08-01" "2023-01-01"
[136] "2023-12-01" "2023-06-01" "2023-02-01" "2023-05-01" "2023-07-01"
[141] "2023-08-01" "2023-10-01" "2023-11-01" "2023-04-01" "2023-02-01"
[146] "2023-01-01" "2023-01-01" "2023-04-01" "2023-01-01" "2023-06-01"
[151] "2023-11-01" "2023-02-01" "2023-04-01" "2023-03-01" "2023-06-01"
[156] "2023-02-01" "2023-07-01" "2023-01-01" "2023-03-01" "2023-01-01"
[161] "2023-04-01" "2023-06-01" "2023-07-01" "2023-10-01" "2023-04-01"
[166] "2023-02-01" "2023-07-01" "2023-06-01" "2023-07-01" "2023-05-01"
[171] "2023-10-01" "2023-03-01" "2023-05-01" "2023-01-01" "2023-05-01"
[176] "2023-05-01" "2023-07-01" "2023-11-01" "2023-11-01" "2023-04-01"
[181] "2023-06-01" "2023-10-01" "2023-12-01" "2023-08-01" "2023-12-01"
[186] "2023-11-01" "2023-10-01" "2023-07-01" "2023-12-01" "2023-02-01"
[191] "2023-02-01" "2023-12-01" "2023-06-01" "2023-01-01" "2023-04-01"
[196] "2023-11-01" "2023-07-01" "2023-07-01" "2023-03-01" "2023-03-01"
[201] "2023-04-01" "2023-07-01" "2023-07-01" "2023-01-01" "2023-03-01"
[206] "2023-02-01" "2023-12-01" "2023-10-01" "2023-06-01" "2023-12-01"
[211] "2023-05-01" "2023-04-01" "2023-03-01" "2023-03-01" "2023-07-01"
[216] "2023-06-01" "2023-11-01" "2023-08-01" "2023-02-01" "2023-12-01"
[221] "2023-02-01" "2023-03-01" "2023-11-01" "2023-04-01" "2023-12-01"
[226] "2023-08-01" "2023-03-01" "2023-04-01" "2023-06-01" "2023-12-01"
[231] "2023-04-01" "2023-11-01" "2023-05-01" "2023-06-01" "2023-04-01"
[236] "2023-07-01" "2023-01-01" "2023-06-01" "2023-02-01" "2023-06-01"
[241] "2023-10-01" "2023-11-01" "2023-08-01" "2023-10-01" "2023-11-01"
[246] "2023-07-01" "2023-11-01" "2023-03-01" "2023-05-01" "2023-01-01"
[251] "2023-03-01" "2023-08-01" "2023-05-01" "2023-02-01" "2023-07-01"
[256] "2023-07-01" "2023-01-01" "2023-06-01" "2023-11-01" "2023-10-01"
[261] "2023-05-01" "2023-11-01" "2023-05-01" "2023-08-01" "2023-07-01"
[266] "2023-08-01" "2023-02-01" "2023-06-01" "2023-10-01" "2023-08-01"
[271] "2023-08-01" "2023-04-01" "2023-08-01" "2023-07-01" "2023-03-01"
[276] "2023-12-01" "2023-01-01" "2023-01-01" "2023-02-01" "2023-06-01"
[281] "2023-08-01" "2023-04-01" "2023-02-01" "2023-06-01" "2023-05-01"
[286] "2023-10-01" "2023-08-01" "2023-06-01" "2023-11-01" "2023-11-01"
[291] "2023-05-01" "2023-02-01" "2023-08-01" "2023-04-01" "2023-08-01"
[296] "2023-01-01" "2023-01-01" "2023-06-01" "2023-12-01" "2023-05-01"
[301] "2023-12-01" "2023-08-01" "2023-05-01" "2023-04-01" "2023-08-01"
[306] "2023-08-01" "2023-03-01" "2023-11-01" "2023-06-01" "2023-02-01"
[311] "2023-12-01" "2023-11-01" "2023-10-01" "2023-01-01" "2023-04-01"
[316] "2023-06-01" "2023-01-01" "2023-08-01" "2023-04-01" "2023-11-01"
[321] "2023-07-01" "2023-12-01" "2023-02-01" "2023-03-01" "2023-10-01"
[326] "2023-07-01" "2023-11-01" "2023-01-01" "2023-08-01" "2023-06-01"
[331] "2023-12-01" "2023-04-01" "2023-02-01" "2023-05-01" "2023-01-01"
[336] "2023-01-01" "2023-12-01" "2023-11-01" "2023-12-01" "2023-07-01"
[341] "2023-11-01" "2023-06-01" "2023-11-01" "2023-02-01" "2023-10-01"
[346] "2023-03-01" "2023-10-01" "2023-02-01" "2023-02-01" "2023-07-01"
[351] "2023-10-01" "2023-11-01" "2023-04-01" "2023-01-01" "2023-08-01"
[356] "2023-12-01" "2023-12-01" "2023-11-01" "2023-11-01" "2023-12-01"
[361] "2023-05-01" "2023-02-01" "2023-03-01" "2023-12-01" "2023-11-01"
[366] "2023-11-01" "2023-02-01" "2023-11-01" "2023-05-01" "2023-03-01"
[371] "2023-03-01" "2023-10-01" "2023-04-01" "2023-03-01" "2023-06-01"
[376] "2023-08-01" "2023-06-01" "2023-03-01" "2023-07-01" "2023-11-01"
[381] "2023-02-01" "2023-08-01" "2023-03-01" "2023-08-01" "2023-01-01"
[386] "2023-04-01" "2023-06-01" "2023-07-01" "2023-04-01" "2023-03-01"
[391] "2023-07-01" "2023-12-01" "2023-05-01" "2023-12-01" "2023-11-01"
[396] "2023-11-01" "2023-02-01" "2023-02-01" "2023-06-01" "2023-08-01"
[401] "2023-01-01" "2023-01-01" "2023-08-01" "2023-12-01" "2023-06-01"
[406] "2023-11-01" "2023-03-01" "2023-04-01" "2023-03-01" "2023-02-01"
[411] "2023-04-01" "2023-11-01" "2023-03-01" "2023-12-01" "2023-04-01"
[416] "2023-10-01" "2023-06-01" "2023-01-01" "2023-03-01" "2023-08-01"
[421] "2023-01-01" "2023-03-01" "2023-02-01" "2023-07-01" "2023-12-01"
[426] "2023-12-01" "2023-03-01" "2023-07-01" "2023-03-01" "2023-03-01"
[431] "2023-05-01" "2023-01-01" "2023-02-01" "2023-01-01" "2023-10-01"
[436] "2023-01-01" "2023-02-01" "2023-05-01" "2023-10-01" "2023-08-01"
[441] "2023-01-01" "2023-03-01" "2023-06-01" "2023-12-01" "2023-05-01"
[446] "2023-08-01" "2023-06-01" "2023-05-01" "2023-03-01" "2023-08-01"
[451] "2023-07-01" "2023-02-01" "2023-06-01" "2023-12-01" "2023-12-01"
[456] "2023-12-01" "2023-10-01" "2023-05-01" "2023-11-01" "2023-02-01"
[461] "2023-03-01" "2023-12-01" "2023-01-01" "2023-07-01" "2023-10-01"
[466] "2023-12-01" "2023-12-01" "2023-07-01" "2023-08-01" "2023-06-01"
[471] "2023-05-01" "2023-08-01" "2023-08-01" "2023-03-01" "2023-07-01"
[476] "2023-02-01" "2023-03-01" "2023-11-01" "2023-03-01" "2023-04-01"
[481] "2023-05-01" "2023-04-01" "2023-08-01" "2023-10-01" "2023-05-01"
[486] "2023-06-01" "2023-11-01" "2023-08-01" "2023-01-01" "2023-11-01"
[491] "2023-12-01" "2023-02-01" "2023-02-01" "2023-11-01" "2023-07-01"
[496] "2023-01-01" "2023-01-01" "2023-07-01" "2023-05-01" "2023-05-01"
[501] "2023-10-01" "2023-12-01" "2023-02-01" "2023-05-01" "2023-05-01"
[506] "2023-04-01" "2023-10-01" "2023-01-01" "2023-10-01" "2023-02-01"
[511] "2023-11-01" "2023-06-01" "2023-05-01" "2023-07-01" "2023-04-01"
[516] "2023-08-01" "2023-12-01" "2023-08-01" "2023-06-01" "2023-06-01"
[521] "2023-03-01" "2023-08-01" "2023-08-01" "2023-05-01" "2023-03-01"
[526] "2023-04-01" "2023-11-01" "2023-01-01" "2023-11-01" "2023-08-01"
[531] "2023-01-01" "2023-04-01" "2023-02-01" "2023-05-01" "2023-05-01"
[536] "2023-04-01" "2023-02-01" "2023-06-01" "2023-12-01" "2023-05-01"
[541] "2023-10-01" "2023-05-01" "2023-05-01" "2023-12-01" "2023-06-01"
[546] "2023-01-01" "2023-12-01" "2023-04-01" "2023-12-01" "2023-07-01"
[551] "2023-01-01" "2023-05-01" "2023-10-01" "2023-03-01" "2023-07-01"
[556] "2023-10-01" "2023-02-01" "2023-10-01" "2023-05-01" "2023-04-01"
[561] "2023-04-01" "2023-10-01" "2023-08-01" "2023-02-01" "2023-10-01"
[566] "2023-04-01" "2023-11-01" "2023-12-01" "2023-04-01" "2023-07-01"
[571] "2023-04-01" "2023-07-01" "2023-12-01" "2023-05-01" "2023-02-01"
[576] "2023-02-01" "2023-06-01" "2023-12-01" "2023-05-01" "2023-04-01"
[581] "2023-03-01" "2023-01-01" "2023-04-01" "2023-04-01" "2023-04-01"
[586] "2023-02-01" "2023-03-01" "2023-12-01" "2023-01-01" "2023-05-01"
[591] "2023-05-01" "2023-10-01" "2023-01-01" "2023-04-01" "2023-10-01"
[596] "2023-06-01" "2023-03-01" "2023-06-01" "2023-02-01" "2023-12-01"
[601] "2023-02-01" "2023-12-01" "2023-03-01" "2023-04-01" "2023-11-01"
[606] "2023-12-01" "2023-10-01" "2023-07-01" "2023-02-01" "2023-05-01"
[611] "2023-10-01" "2023-05-01" "2023-03-01" "2023-10-01" "2023-02-01"
[616] "2023-12-01" "2023-01-01" "2023-05-01" "2023-03-01" "2023-01-01"
[621] "2023-11-01" "2023-02-01" "2023-03-01" "2023-01-01" "2023-04-01"
[626] "2023-03-01" "2023-06-01" "2023-12-01" "2023-08-01" "2023-01-01"
[631] "2023-06-01" "2023-12-01" "2023-02-01" "2023-03-01" "2023-10-01"
[636] "2023-10-01" "2023-03-01" "2023-03-01" "2023-08-01" "2023-12-01"
[641] "2023-02-01" "2023-05-01" "2023-11-01" "2023-12-01" "2023-05-01"
[646] "2023-06-01" "2023-07-01" "2023-08-01" "2023-12-01" "2023-11-01"
[651] "2023-05-01" "2023-07-01" "2023-01-01" "2023-02-01" "2023-01-01"
[656] "2023-07-01" "2023-10-01" "2023-06-01" "2023-07-01" "2023-08-01"
[661] "2023-07-01" "2023-08-01" "2023-04-01" "2023-11-01" "2023-03-01"
[666] "2023-08-01" "2023-10-01" "2023-01-01" "2023-11-01" "2023-02-01"
[671] "2023-04-01" "2023-01-01" "2023-06-01" "2023-02-01" "2023-12-01"
[676] "2023-03-01" "2023-05-01" "2023-07-01" "2023-01-01" "2023-03-01"
[681] "2023-12-01" "2023-03-01" "2023-04-01" "2023-10-01" "2023-10-01"
[686] "2023-11-01" "2023-11-01" "2023-10-01" "2023-01-01" "2023-10-01"
[691] "2023-11-01" "2023-01-01" "2023-03-01" "2023-11-01" "2023-11-01"
[696] "2023-04-01" "2023-04-01" "2023-11-01" "2023-08-01" "2023-04-01"
[701] "2023-06-01" "2023-06-01" "2023-06-01" "2023-07-01" "2023-12-01"
[706] "2023-08-01" "2023-10-01" "2023-10-01" "2023-12-01" "2023-06-01"
[711] "2023-07-01" "2023-07-01" "2023-01-01" "2023-10-01" "2023-02-01"
[716] "2023-07-01" "2023-05-01" "2023-06-01" "2023-07-01" "2023-02-01"
[721] "2023-04-01" "2023-02-01" "2023-03-01" "2023-10-01" "2023-08-01"
[726] "2023-05-01" "2023-06-01" "2023-07-01" "2023-11-01" "2023-02-01"
[731] "2023-05-01" "2023-02-01" "2023-07-01" "2023-06-01" "2023-10-01"
[736] "2023-10-01" "2023-07-01" "2023-02-01" "2023-10-01" "2023-01-01"
[741] "2023-11-01" "2023-10-01" "2023-06-01" "2023-10-01" "2023-03-01"
[746] "2023-02-01" "2023-07-01" "2023-05-01" "2023-10-01" "2023-04-01"
[751] "2023-03-01" "2023-01-01" "2023-12-01" "2023-12-01" "2023-10-01"
[756] "2023-06-01" "2023-01-01" "2023-06-01" "2023-04-01" "2023-03-01"
[761] "2023-06-01" "2023-07-01" "2023-12-01" "2023-05-01" "2023-04-01"
[766] "2023-07-01" "2023-11-01" "2023-07-01" "2023-02-01" "2023-01-01"
[771] "2023-04-01" "2023-12-01" "2023-11-01" "2023-10-01" "2023-10-01"
[776] "2023-03-01" "2023-12-01" "2023-01-01" "2023-11-01" "2023-11-01"
[781] "2023-04-01" "2023-10-01" "2023-06-01" "2023-02-01" "2023-12-01"
[786] "2023-05-01" "2023-11-01" "2023-06-01" "2023-08-01" "2023-08-01"
[791] "2023-03-01" "2023-08-01" "2023-04-01" "2023-11-01" "2023-07-01"
[796] "2023-02-01" "2023-05-01" "2023-11-01" "2023-04-01" "2023-06-01"
[801] "2023-06-01" "2023-01-01" "2023-06-01" "2023-05-01" "2023-10-01"
[806] "2023-12-01" "2023-12-01" "2023-02-01" "2023-07-01" "2023-04-01"
[811] "2023-04-01" "2023-07-01" "2023-04-01" "2023-08-01" "2023-01-01"
[816] "2023-12-01" "2023-01-01" "2023-05-01" "2023-07-01" "2023-11-01"
2. Based on the GIS tutorial (Japan earthquakes), create one plot about something in your subsetted dataset.
First plot chunk here
The first plot is a geom_density of the inbound border crossing in each state that is along the US-Canada border
ggplot(us_cana_2023, aes(x= Date , color= State)) +
geom_density(alpha = 0.4) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
labs(title = "Average Inbound US-Canada Border Crossing via Trucks in 2023",
y = "Density",
caption = "https://catalog.data.gov/dataset/border-crossing-entry-data-683ae")+
scale_color_brewer(type = "div", palette = 1) +
theme_grey(base_size = 12)The seconf plot is a geom_density of the inbound border crossing in each state that is along the US-Mexico border.
ggplot(us_mex_2023, aes(x= Date , color= State)) +
geom_density(alpha = 0.4) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
labs(title = "Average Inbound US-Mexico Border Crossing via Trucks in 2023",
y = "Density",
caption = "https://catalog.data.gov/dataset/border-crossing-entry-data-683ae")+
scale_color_brewer(type = "div", palette = 1) +
theme_grey(base_size = 12)3. Now create a map of your subsetted dataset.
First map chunk here I wanted a map that visualized both borders. Instead of plotting one border, I wanted both borders. I started the process again so that I would have one data set, instead of two.
special_border_df <- border_df |>
filter(Measure == "Trucks")|>
group_by(`Port Name`)|>
mutate(total_Value = sum(Value),
mean_Value = round(mean(Value)), 2)
borders_2023 <- subset(special_border_df, Date %in% c("Jan 2023", "Feb 2023", "Mar 2023", "Apr 2023", "May 2023", "Jun 2023", "Jul 2023", "Aug 2023" , "Sept 2023", "Oct 2023", "Nov 2023", "Dec 2023"))
borders_2023$Date <- as.Date(paste("01", borders_2023$Date), format = "%d %B %Y")
borders_2023$Date [1] "2023-12-01" "2023-11-01" "2023-08-01" "2023-08-01" "2023-08-01"
[6] "2023-03-01" "2023-02-01" "2023-02-01" "2023-01-01" "2023-07-01"
[11] "2023-07-01" "2023-11-01" "2023-11-01" "2023-01-01" "2023-10-01"
[16] "2023-04-01" "2023-03-01" "2023-10-01" "2023-08-01" "2023-07-01"
[21] "2023-04-01" "2023-05-01" "2023-04-01" "2023-04-01" "2023-05-01"
[26] "2023-03-01" "2023-06-01" "2023-02-01" "2023-08-01" "2023-07-01"
[31] "2023-05-01" "2023-06-01" "2023-01-01" "2023-11-01" "2023-02-01"
[36] "2023-02-01" "2023-11-01" "2023-03-01" "2023-02-01" "2023-06-01"
[41] "2023-12-01" "2023-07-01" "2023-01-01" "2023-08-01" "2023-10-01"
[46] "2023-01-01" "2023-05-01" "2023-04-01" "2023-12-01" "2023-02-01"
[51] "2023-01-01" "2023-10-01" "2023-06-01" "2023-05-01" "2023-12-01"
[56] "2023-05-01" "2023-06-01" "2023-08-01" "2023-11-01" "2023-05-01"
[61] "2023-05-01" "2023-11-01" "2023-01-01" "2023-08-01" "2023-01-01"
[66] "2023-04-01" "2023-10-01" "2023-07-01" "2023-02-01" "2023-03-01"
[71] "2023-08-01" "2023-01-01" "2023-12-01" "2023-07-01" "2023-05-01"
[76] "2023-08-01" "2023-03-01" "2023-04-01" "2023-05-01" "2023-08-01"
[81] "2023-01-01" "2023-07-01" "2023-05-01" "2023-07-01" "2023-04-01"
[86] "2023-08-01" "2023-10-01" "2023-10-01" "2023-04-01" "2023-08-01"
[91] "2023-06-01" "2023-01-01" "2023-10-01" "2023-05-01" "2023-12-01"
[96] "2023-03-01" "2023-02-01" "2023-08-01" "2023-02-01" "2023-03-01"
[101] "2023-07-01" "2023-08-01" "2023-11-01" "2023-07-01" "2023-06-01"
[106] "2023-11-01" "2023-08-01" "2023-01-01" "2023-03-01" "2023-10-01"
[111] "2023-11-01" "2023-12-01" "2023-06-01" "2023-11-01" "2023-06-01"
[116] "2023-11-01" "2023-04-01" "2023-05-01" "2023-03-01" "2023-10-01"
[121] "2023-06-01" "2023-07-01" "2023-01-01" "2023-12-01" "2023-10-01"
[126] "2023-02-01" "2023-05-01" "2023-01-01" "2023-06-01" "2023-01-01"
[131] "2023-07-01" "2023-07-01" "2023-07-01" "2023-10-01" "2023-04-01"
[136] "2023-10-01" "2023-05-01" "2023-01-01" "2023-05-01" "2023-03-01"
[141] "2023-08-01" "2023-08-01" "2023-01-01" "2023-03-01" "2023-04-01"
[146] "2023-10-01" "2023-08-01" "2023-03-01" "2023-08-01" "2023-06-01"
[151] "2023-12-01" "2023-11-01" "2023-05-01" "2023-05-01" "2023-03-01"
[156] "2023-10-01" "2023-03-01" "2023-06-01" "2023-12-01" "2023-05-01"
[161] "2023-08-01" "2023-01-01" "2023-12-01" "2023-02-01" "2023-10-01"
[166] "2023-03-01" "2023-06-01" "2023-12-01" "2023-02-01" "2023-05-01"
[171] "2023-07-01" "2023-08-01" "2023-10-01" "2023-11-01" "2023-04-01"
[176] "2023-02-01" "2023-05-01" "2023-01-01" "2023-01-01" "2023-04-01"
[181] "2023-01-01" "2023-06-01" "2023-11-01" "2023-02-01" "2023-04-01"
[186] "2023-03-01" "2023-06-01" "2023-08-01" "2023-02-01" "2023-07-01"
[191] "2023-01-01" "2023-03-01" "2023-01-01" "2023-04-01" "2023-12-01"
[196] "2023-06-01" "2023-07-01" "2023-10-01" "2023-04-01" "2023-02-01"
[201] "2023-11-01" "2023-02-01" "2023-07-01" "2023-06-01" "2023-07-01"
[206] "2023-05-01" "2023-10-01" "2023-12-01" "2023-03-01" "2023-05-01"
[211] "2023-01-01" "2023-05-01" "2023-05-01" "2023-07-01" "2023-11-01"
[216] "2023-11-01" "2023-04-01" "2023-10-01" "2023-06-01" "2023-10-01"
[221] "2023-10-01" "2023-12-01" "2023-08-01" "2023-12-01" "2023-11-01"
[226] "2023-10-01" "2023-05-01" "2023-07-01" "2023-12-01" "2023-02-01"
[231] "2023-02-01" "2023-12-01" "2023-06-01" "2023-01-01" "2023-06-01"
[236] "2023-06-01" "2023-04-01" "2023-06-01" "2023-11-01" "2023-07-01"
[241] "2023-07-01" "2023-03-01" "2023-03-01" "2023-03-01" "2023-04-01"
[246] "2023-05-01" "2023-07-01" "2023-07-01" "2023-01-01" "2023-12-01"
[251] "2023-03-01" "2023-08-01" "2023-02-01" "2023-12-01" "2023-06-01"
[256] "2023-10-01" "2023-06-01" "2023-12-01" "2023-05-01" "2023-04-01"
[261] "2023-03-01" "2023-03-01" "2023-05-01" "2023-07-01" "2023-06-01"
[266] "2023-11-01" "2023-08-01" "2023-02-01" "2023-12-01" "2023-02-01"
[271] "2023-06-01" "2023-03-01" "2023-11-01" "2023-11-01" "2023-04-01"
[276] "2023-06-01" "2023-06-01" "2023-12-01" "2023-07-01" "2023-08-01"
[281] "2023-03-01" "2023-04-01" "2023-06-01" "2023-12-01" "2023-04-01"
[286] "2023-11-01" "2023-05-01" "2023-06-01" "2023-06-01" "2023-04-01"
[291] "2023-03-01" "2023-07-01" "2023-04-01" "2023-08-01" "2023-12-01"
[296] "2023-01-01" "2023-06-01" "2023-08-01" "2023-02-01" "2023-06-01"
[301] "2023-10-01" "2023-11-01" "2023-02-01" "2023-08-01" "2023-10-01"
[306] "2023-11-01" "2023-07-01" "2023-11-01" "2023-03-01" "2023-05-01"
[311] "2023-01-01" "2023-03-01" "2023-08-01" "2023-05-01" "2023-10-01"
[316] "2023-02-01" "2023-07-01" "2023-07-01" "2023-01-01" "2023-04-01"
[321] "2023-06-01" "2023-11-01" "2023-10-01" "2023-05-01" "2023-11-01"
[326] "2023-05-01" "2023-08-01" "2023-07-01" "2023-08-01" "2023-02-01"
[331] "2023-06-01" "2023-10-01" "2023-08-01" "2023-08-01" "2023-04-01"
[336] "2023-08-01" "2023-07-01" "2023-03-01" "2023-12-01" "2023-11-01"
[341] "2023-01-01" "2023-01-01" "2023-02-01" "2023-03-01" "2023-06-01"
[346] "2023-08-01" "2023-04-01" "2023-02-01" "2023-06-01" "2023-05-01"
[351] "2023-10-01" "2023-11-01" "2023-08-01" "2023-10-01" "2023-06-01"
[356] "2023-10-01" "2023-11-01" "2023-11-01" "2023-05-01" "2023-02-01"
[361] "2023-08-01" "2023-04-01" "2023-01-01" "2023-08-01" "2023-08-01"
[366] "2023-01-01" "2023-01-01" "2023-06-01" "2023-12-01" "2023-05-01"
[371] "2023-08-01" "2023-12-01" "2023-08-01" "2023-05-01" "2023-04-01"
[376] "2023-10-01" "2023-10-01" "2023-08-01" "2023-06-01" "2023-08-01"
[381] "2023-03-01" "2023-11-01" "2023-06-01" "2023-04-01" "2023-02-01"
[386] "2023-12-01" "2023-01-01" "2023-04-01" "2023-05-01" "2023-03-01"
[391] "2023-11-01" "2023-10-01" "2023-01-01" "2023-04-01" "2023-06-01"
[396] "2023-01-01" "2023-05-01" "2023-08-01" "2023-04-01" "2023-11-01"
[401] "2023-07-01" "2023-12-01" "2023-02-01" "2023-03-01" "2023-02-01"
[406] "2023-11-01" "2023-10-01" "2023-07-01" "2023-11-01" "2023-01-01"
[411] "2023-08-01" "2023-06-01" "2023-12-01" "2023-04-01" "2023-02-01"
[416] "2023-05-01" "2023-01-01" "2023-01-01" "2023-12-01" "2023-11-01"
[421] "2023-12-01" "2023-07-01" "2023-11-01" "2023-06-01" "2023-11-01"
[426] "2023-02-01" "2023-10-01" "2023-03-01" "2023-10-01" "2023-02-01"
[431] "2023-03-01" "2023-02-01" "2023-11-01" "2023-07-01" "2023-10-01"
[436] "2023-11-01" "2023-04-01" "2023-01-01" "2023-08-01" "2023-12-01"
[441] "2023-12-01" "2023-11-01" "2023-11-01" "2023-12-01" "2023-11-01"
[446] "2023-05-01" "2023-02-01" "2023-03-01" "2023-12-01" "2023-11-01"
[451] "2023-11-01" "2023-02-01" "2023-11-01" "2023-11-01" "2023-05-01"
[456] "2023-03-01" "2023-03-01" "2023-10-01" "2023-04-01" "2023-03-01"
[461] "2023-06-01" "2023-08-01" "2023-06-01" "2023-12-01" "2023-03-01"
[466] "2023-07-01" "2023-11-01" "2023-02-01" "2023-08-01" "2023-04-01"
[471] "2023-03-01" "2023-08-01" "2023-01-01" "2023-04-01" "2023-10-01"
[476] "2023-06-01" "2023-07-01" "2023-07-01" "2023-04-01" "2023-03-01"
[481] "2023-12-01" "2023-07-01" "2023-01-01" "2023-12-01" "2023-05-01"
[486] "2023-01-01" "2023-12-01" "2023-11-01" "2023-11-01" "2023-02-01"
[491] "2023-02-01" "2023-06-01" "2023-08-01" "2023-01-01" "2023-03-01"
[496] "2023-01-01" "2023-08-01" "2023-12-01" "2023-02-01" "2023-12-01"
[501] "2023-06-01" "2023-03-01" "2023-10-01" "2023-03-01" "2023-11-01"
[506] "2023-02-01" "2023-03-01" "2023-04-01" "2023-03-01" "2023-02-01"
[511] "2023-04-01" "2023-10-01" "2023-11-01" "2023-03-01" "2023-12-01"
[516] "2023-04-01" "2023-03-01" "2023-10-01" "2023-06-01" "2023-03-01"
[521] "2023-01-01" "2023-03-01" "2023-08-01" "2023-01-01" "2023-03-01"
[526] "2023-02-01" "2023-07-01" "2023-12-01" "2023-12-01" "2023-03-01"
[531] "2023-03-01" "2023-04-01" "2023-07-01" "2023-03-01" "2023-03-01"
[536] "2023-05-01" "2023-01-01" "2023-11-01" "2023-02-01" "2023-01-01"
[541] "2023-08-01" "2023-10-01" "2023-01-01" "2023-02-01" "2023-05-01"
[546] "2023-10-01" "2023-07-01" "2023-07-01" "2023-08-01" "2023-01-01"
[551] "2023-01-01" "2023-03-01" "2023-03-01" "2023-06-01" "2023-12-01"
[556] "2023-05-01" "2023-08-01" "2023-03-01" "2023-06-01" "2023-05-01"
[561] "2023-03-01" "2023-08-01" "2023-02-01" "2023-07-01" "2023-02-01"
[566] "2023-06-01" "2023-12-01" "2023-12-01" "2023-12-01" "2023-12-01"
[571] "2023-10-01" "2023-10-01" "2023-06-01" "2023-05-01" "2023-11-01"
[576] "2023-11-01" "2023-02-01" "2023-03-01" "2023-12-01" "2023-01-01"
[581] "2023-07-01" "2023-10-01" "2023-12-01" "2023-11-01" "2023-12-01"
[586] "2023-07-01" "2023-08-01" "2023-06-01" "2023-05-01" "2023-08-01"
[591] "2023-08-01" "2023-03-01" "2023-07-01" "2023-02-01" "2023-03-01"
[596] "2023-11-01" "2023-03-01" "2023-04-01" "2023-05-01" "2023-05-01"
[601] "2023-04-01" "2023-08-01" "2023-10-01" "2023-02-01" "2023-10-01"
[606] "2023-05-01" "2023-06-01" "2023-02-01" "2023-11-01" "2023-04-01"
[611] "2023-08-01" "2023-01-01" "2023-05-01" "2023-11-01" "2023-02-01"
[616] "2023-12-01" "2023-02-01" "2023-02-01" "2023-06-01" "2023-11-01"
[621] "2023-07-01" "2023-01-01" "2023-01-01" "2023-07-01" "2023-12-01"
[626] "2023-05-01" "2023-04-01" "2023-05-01" "2023-10-01" "2023-12-01"
[631] "2023-05-01" "2023-07-01" "2023-02-01" "2023-06-01" "2023-11-01"
[636] "2023-10-01" "2023-05-01" "2023-05-01" "2023-04-01" "2023-10-01"
[641] "2023-01-01" "2023-10-01" "2023-02-01" "2023-11-01" "2023-07-01"
[646] "2023-06-01" "2023-05-01" "2023-01-01" "2023-07-01" "2023-04-01"
[651] "2023-08-01" "2023-12-01" "2023-08-01" "2023-06-01" "2023-06-01"
[656] "2023-03-01" "2023-08-01" "2023-08-01" "2023-05-01" "2023-04-01"
[661] "2023-03-01" "2023-04-01" "2023-11-01" "2023-06-01" "2023-01-01"
[666] "2023-11-01" "2023-08-01" "2023-01-01" "2023-04-01" "2023-02-01"
[671] "2023-05-01" "2023-05-01" "2023-04-01" "2023-07-01" "2023-02-01"
[676] "2023-04-01" "2023-06-01" "2023-12-01" "2023-05-01" "2023-08-01"
[681] "2023-01-01" "2023-10-01" "2023-05-01" "2023-04-01" "2023-05-01"
[686] "2023-12-01" "2023-06-01" "2023-12-01" "2023-01-01" "2023-12-01"
[691] "2023-04-01" "2023-12-01" "2023-04-01" "2023-07-01" "2023-01-01"
[696] "2023-07-01" "2023-05-01" "2023-10-01" "2023-03-01" "2023-07-01"
[701] "2023-10-01" "2023-02-01" "2023-10-01" "2023-05-01" "2023-04-01"
[706] "2023-04-01" "2023-10-01" "2023-08-01" "2023-02-01" "2023-01-01"
[711] "2023-10-01" "2023-04-01" "2023-11-01" "2023-12-01" "2023-04-01"
[716] "2023-07-01" "2023-04-01" "2023-07-01" "2023-12-01" "2023-05-01"
[721] "2023-02-01" "2023-02-01" "2023-01-01" "2023-07-01" "2023-06-01"
[726] "2023-12-01" "2023-05-01" "2023-04-01" "2023-03-01" "2023-01-01"
[731] "2023-04-01" "2023-04-01" "2023-04-01" "2023-02-01" "2023-03-01"
[736] "2023-12-01" "2023-01-01" "2023-05-01" "2023-11-01" "2023-10-01"
[741] "2023-05-01" "2023-08-01" "2023-02-01" "2023-10-01" "2023-10-01"
[746] "2023-01-01" "2023-08-01" "2023-04-01" "2023-10-01" "2023-06-01"
[751] "2023-03-01" "2023-06-01" "2023-02-01" "2023-07-01" "2023-12-01"
[756] "2023-02-01" "2023-12-01" "2023-03-01" "2023-04-01" "2023-11-01"
[761] "2023-12-01" "2023-10-01" "2023-07-01" "2023-02-01" "2023-05-01"
[766] "2023-10-01" "2023-05-01" "2023-03-01" "2023-10-01" "2023-11-01"
[771] "2023-02-01" "2023-12-01" "2023-01-01" "2023-05-01" "2023-03-01"
[776] "2023-01-01" "2023-11-01" "2023-12-01" "2023-02-01" "2023-03-01"
[781] "2023-01-01" "2023-04-01" "2023-01-01" "2023-03-01" "2023-06-01"
[786] "2023-12-01" "2023-12-01" "2023-08-01" "2023-08-01" "2023-01-01"
[791] "2023-04-01" "2023-05-01" "2023-06-01" "2023-06-01" "2023-12-01"
[796] "2023-02-01" "2023-01-01" "2023-03-01" "2023-10-01" "2023-10-01"
[801] "2023-03-01" "2023-03-01" "2023-08-01" "2023-12-01" "2023-02-01"
[806] "2023-05-01" "2023-11-01" "2023-12-01" "2023-03-01" "2023-05-01"
[811] "2023-04-01" "2023-06-01" "2023-07-01" "2023-08-01" "2023-05-01"
[816] "2023-12-01" "2023-11-01" "2023-02-01" "2023-04-01" "2023-05-01"
[821] "2023-07-01" "2023-07-01" "2023-01-01" "2023-02-01" "2023-01-01"
[826] "2023-07-01" "2023-10-01" "2023-07-01" "2023-02-01" "2023-08-01"
[831] "2023-06-01" "2023-07-01" "2023-02-01" "2023-08-01" "2023-07-01"
[836] "2023-08-01" "2023-04-01" "2023-11-01" "2023-03-01" "2023-08-01"
[841] "2023-10-01" "2023-01-01" "2023-11-01" "2023-02-01" "2023-04-01"
[846] "2023-01-01" "2023-06-01" "2023-02-01" "2023-12-01" "2023-03-01"
[851] "2023-05-01" "2023-07-01" "2023-01-01" "2023-03-01" "2023-12-01"
[856] "2023-12-01" "2023-03-01" "2023-04-01" "2023-10-01" "2023-11-01"
[861] "2023-10-01" "2023-11-01" "2023-11-01" "2023-01-01" "2023-10-01"
[866] "2023-01-01" "2023-10-01" "2023-01-01" "2023-11-01" "2023-04-01"
[871] "2023-01-01" "2023-03-01" "2023-05-01" "2023-11-01" "2023-11-01"
[876] "2023-04-01" "2023-04-01" "2023-11-01" "2023-08-01" "2023-04-01"
[881] "2023-06-01" "2023-06-01" "2023-08-01" "2023-06-01" "2023-07-01"
[886] "2023-12-01" "2023-08-01" "2023-10-01" "2023-10-01" "2023-12-01"
[891] "2023-05-01" "2023-06-01" "2023-07-01" "2023-10-01" "2023-07-01"
[896] "2023-01-01" "2023-10-01" "2023-04-01" "2023-02-01" "2023-07-01"
[901] "2023-05-01" "2023-06-01" "2023-07-01" "2023-02-01" "2023-07-01"
[906] "2023-04-01" "2023-06-01" "2023-02-01" "2023-03-01" "2023-10-01"
[911] "2023-04-01" "2023-08-01" "2023-08-01" "2023-05-01" "2023-06-01"
[916] "2023-07-01" "2023-11-01" "2023-02-01" "2023-11-01" "2023-10-01"
[921] "2023-08-01" "2023-05-01" "2023-02-01" "2023-10-01" "2023-07-01"
[926] "2023-06-01" "2023-10-01" "2023-10-01" "2023-06-01" "2023-10-01"
[931] "2023-07-01" "2023-02-01" "2023-10-01" "2023-01-01" "2023-11-01"
[936] "2023-10-01" "2023-11-01" "2023-06-01" "2023-10-01" "2023-06-01"
[941] "2023-03-01" "2023-02-01" "2023-07-01" "2023-05-01" "2023-10-01"
[946] "2023-04-01" "2023-03-01" "2023-03-01" "2023-07-01" "2023-01-01"
[951] "2023-12-01" "2023-11-01" "2023-12-01" "2023-03-01" "2023-10-01"
[956] "2023-06-01" "2023-08-01" "2023-01-01" "2023-06-01" "2023-12-01"
[961] "2023-04-01" "2023-03-01" "2023-02-01" "2023-06-01" "2023-07-01"
[966] "2023-12-01" "2023-05-01" "2023-01-01" "2023-12-01" "2023-02-01"
[971] "2023-04-01" "2023-12-01" "2023-12-01" "2023-07-01" "2023-11-01"
[976] "2023-07-01" "2023-12-01" "2023-02-01" "2023-07-01" "2023-01-01"
[981] "2023-01-01" "2023-04-01" "2023-12-01" "2023-11-01" "2023-08-01"
[986] "2023-07-01" "2023-08-01" "2023-07-01" "2023-11-01" "2023-10-01"
[991] "2023-10-01" "2023-03-01" "2023-12-01" "2023-05-01" "2023-01-01"
[996] "2023-11-01" "2023-11-01" "2023-06-01" "2023-04-01" "2023-10-01"
[1001] "2023-07-01" "2023-02-01" "2023-06-01" "2023-08-01" "2023-02-01"
[1006] "2023-02-01" "2023-12-01" "2023-05-01" "2023-11-01" "2023-06-01"
[1011] "2023-08-01" "2023-06-01" "2023-08-01" "2023-03-01" "2023-05-01"
[1016] "2023-12-01" "2023-08-01" "2023-04-01" "2023-08-01" "2023-11-01"
[1021] "2023-07-01" "2023-02-01" "2023-05-01" "2023-11-01" "2023-04-01"
[1026] "2023-06-01" "2023-06-01" "2023-01-01" "2023-10-01" "2023-06-01"
[1031] "2023-05-01" "2023-05-01" "2023-11-01" "2023-10-01" "2023-12-01"
[1036] "2023-12-01" "2023-02-01" "2023-07-01" "2023-04-01" "2023-04-01"
[1041] "2023-03-01" "2023-04-01" "2023-07-01" "2023-04-01" "2023-04-01"
[1046] "2023-10-01" "2023-08-01" "2023-01-01" "2023-12-01" "2023-01-01"
[1051] "2023-05-01" "2023-03-01" "2023-07-01" "2023-07-01" "2023-11-01"
Map of the subsetted data
library(leaflet)
library(sf)Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(tidyverse)
library(knitr)
leaflet() |>
setView(lng = -119.462, lat = 49, zoom =3) |> # Washington State
addProviderTiles("Esri.WorldStreetMap") |>
addCircles(
data = borders_2023,
radius = borders_2023$mean_Value
)Assuming "Longitude" and "Latitude" are longitude and latitude, respectively
4. Refine your map to include a mouse-click tooltip
Refined map chunk here
leaflet() |>
setView(lng = -75.458, lat = 44, zoom =4) |> # New York
addProviderTiles("Esri.WorldStreetMap") |>
addCircles(
data = borders_2023,
radius = borders_2023$mean_Value,
color = "#00AFBB",
fillColor = "#E7B800",
fillOpacity = 0.25
)Assuming "Longitude" and "Latitude" are longitude and latitude, respectively
popup <- paste0(
"<b>When: </b>", borders_2023$Date, "<br>",
"<b>Post Name: </b>", borders_2023$`Port Name`, "<br>",
"<b>State: </b>", borders_2023$State, "<br>",
"<b>Mean Value: </b>", borders_2023$mean_Value, "<br>"
)4. Refine your map to include a mouse-click tooltip
Refined map chunk here
leaflet() |>
setView(lng = -75.458, lat = 44, zoom =5) |> # New York state
addProviderTiles("Esri.WorldStreetMap") |>
addCircles(
data = borders_2023,
radius = borders_2023$mean_Value,
color = "#00AFBB",
fillColor = "#E7B800",
fillOpacity = 0.35,
popup = popup)Assuming "Longitude" and "Latitude" are longitude and latitude, respectively
5. Write a paragraph
In a paragraph, describe the plots you created and what they show.
https://catalog.data.gov/dataset/border-crossing-entry-data-683ae
The data that I used is “the Bureau of Transportation Statistics (BTS) Border Crossing Data [that] provided summary statistics for inbound crossings at the U.S.-Canada and the U.S.-Mexico border at the port level.” The original data set contained 395,638 observations and 10 variables. I created 6 subsetted data sets: us_cana, us_cana_2023, us_mex, us_mex_2023, special_border_df, and special border_2023. I had originally utilized one data set that explored the US-Canada border, but after further analysis, I decided that it would be better to plot the data for both borders to allow viewers to make comparative observations.
I started the process by filtering the data. I wanted to narrow down my data set to a specific “measure” (way of transport) which was trucks. Then I created two additional columns that generates the sum of the “value” (number of inbound crossings) and the average of the “value.” The first plot is a density plot that illustrates the states along the US-Canada border. In the first plot, North Dakota appeared to be the state with highest number of crossings up until around June. The second plot is another density plot, but it illustrates the states along the US-Mexico border. The last map with the mouse over attribute, plots the average number of crossings based on ports. In the visualization, it appears the state with the largest average along the US-Canada border is Detroit Michigan with an average of 129,634 crossings and the largest average along the US-Mexico border is Laredo, Texas with 151,922 crossings.