This analysis will be taking a look at binge drinking in the United States compared to Google Searches for ‘frat parties’ and ‘college alcohol.’
library(tidyverse)
library(broom)
library(plotly)
library(tidycensus) # gets census data that we can use to create maps
library(sf) # helper package for mapping
library(leaflet) # interactive mapping package
library(trendyy)
library(usdata) # this package has a conversion utility for state abbreviations to full names
v19 <- load_variables(2019, "acs5", cache = TRUE)
states <- get_acs(geography = "state", # gets state by state data
variables = "B01003_001", # this is state population
geometry = TRUE, # gets geometry (the maps)
shift_geo = T) # shifts Hawaii and Alaska
Getting data from the 2015-2019 5-year ACS
Using feature geometry obtained from the albersusa package
Please note: Alaska and Hawaii are being shifted and are not to scale.
states
First off, the words ‘binge drinking’ make me think of the student population in Montana. The maps below show the population of undergrad and graduates students in Montana counties. I retrieved the codes from the most recent ACS survey. The undergrad code represents those enrolled in undergraduate courses and includes up to four races. The grad code was also taken from the same ACS survey, and from the same list.
undergrad_pop_MT <- get_acs(geography = "county",
state = "MT",
variables = "B14007G_017",
geometry = TRUE)
Getting data from the 2015-2019 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '30' for state 'MT'
|
| | 0%
|
|= | 1%
|
|== | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|==== | 4%
|
|===== | 4%
|
|===== | 5%
|
|====== | 5%
|
|======= | 6%
|
|======== | 6%
|
|======== | 7%
|
|========= | 7%
|
|========= | 8%
|
|========== | 8%
|
|========== | 9%
|
|=========== | 9%
|
|=========== | 10%
|
|============ | 10%
|
|============= | 11%
|
|============== | 11%
|
|============== | 12%
|
|=============== | 12%
|
|=============== | 13%
|
|================ | 13%
|
|================ | 14%
|
|================= | 14%
|
|================= | 15%
|
|================== | 15%
|
|=================== | 16%
|
|==================== | 16%
|
|==================== | 17%
|
|===================== | 17%
|
|===================== | 18%
|
|====================== | 18%
|
|====================== | 19%
|
|======================= | 19%
|
|======================= | 20%
|
|======================== | 20%
|
|========================= | 21%
|
|========================== | 22%
|
|=========================== | 22%
|
|=========================== | 23%
|
|============================ | 23%
|
|============================ | 24%
|
|============================= | 24%
|
|============================= | 25%
|
|============================== | 25%
|
|============================== | 26%
|
|=============================== | 26%
|
|================================ | 27%
|
|================================= | 27%
|
|================================= | 28%
|
|================================== | 28%
|
|================================== | 29%
|
|=================================== | 29%
|
|=================================== | 30%
|
|==================================== | 30%
|
|==================================== | 31%
|
|===================================== | 31%
|
|====================================== | 32%
|
|======================================= | 32%
|
|======================================= | 33%
|
|======================================== | 33%
|
|======================================== | 34%
|
|========================================= | 34%
|
|========================================= | 35%
|
|========================================== | 35%
|
|========================================== | 36%
|
|=========================================== | 36%
|
|=========================================== | 37%
|
|============================================ | 37%
|
|============================================= | 37%
|
|============================================= | 38%
|
|============================================== | 38%
|
|============================================== | 39%
|
|=============================================== | 39%
|
|=============================================== | 40%
|
|================================================ | 40%
|
|================================================ | 41%
|
|================================================= | 41%
|
|================================================= | 42%
|
|================================================== | 42%
|
|=================================================== | 43%
|
|==================================================== | 43%
|
|==================================================== | 44%
|
|===================================================== | 44%
|
|===================================================== | 45%
|
|====================================================== | 45%
|
|====================================================== | 46%
|
|======================================================= | 46%
|
|======================================================= | 47%
|
|======================================================== | 47%
|
|========================================================= | 48%
|
|========================================================== | 48%
|
|========================================================== | 49%
|
|=========================================================== | 49%
|
|=========================================================== | 50%
|
|============================================================ | 50%
|
|============================================================ | 51%
|
|============================================================= | 51%
|
|============================================================= | 52%
|
|============================================================== | 52%
|
|=============================================================== | 53%
|
|================================================================ | 53%
|
|================================================================ | 54%
|
|================================================================= | 54%
|
|================================================================= | 55%
|
|================================================================== | 55%
|
|================================================================== | 56%
|
|=================================================================== | 56%
|
|=================================================================== | 57%
|
|==================================================================== | 57%
|
|===================================================================== | 58%
|
|====================================================================== | 58%
|
|====================================================================== | 59%
|
|======================================================================= | 59%
|
|======================================================================= | 60%
|
|======================================================================== | 60%
|
|======================================================================== | 61%
|
|========================================================================= | 61%
|
|========================================================================= | 62%
|
|========================================================================== | 62%
|
|========================================================================== | 63%
|
|=========================================================================== | 63%
|
|============================================================================ | 63%
|
|============================================================================ | 64%
|
|============================================================================= | 64%
|
|============================================================================= | 65%
|
|============================================================================== | 65%
|
|============================================================================== | 66%
|
|=============================================================================== | 66%
|
|=============================================================================== | 67%
|
|================================================================================ | 67%
|
|================================================================================ | 68%
|
|================================================================================= | 68%
|
|================================================================================== | 69%
|
|=================================================================================== | 69%
|
|=================================================================================== | 70%
|
|==================================================================================== | 70%
|
|==================================================================================== | 71%
|
|===================================================================================== | 71%
|
|===================================================================================== | 72%
|
|====================================================================================== | 72%
|
|====================================================================================== | 73%
|
|======================================================================================= | 73%
|
|======================================================================================== | 74%
|
|========================================================================================= | 74%
|
|========================================================================================= | 75%
|
|========================================================================================== | 75%
|
|========================================================================================== | 76%
|
|=========================================================================================== | 76%
|
|=========================================================================================== | 77%
|
|============================================================================================ | 77%
|
|============================================================================================ | 78%
|
|============================================================================================= | 78%
|
|============================================================================================== | 79%
|
|=============================================================================================== | 80%
|
|================================================================================================ | 80%
|
|================================================================================================ | 81%
|
|================================================================================================= | 81%
|
|================================================================================================= | 82%
|
|================================================================================================== | 82%
|
|================================================================================================== | 83%
|
|=================================================================================================== | 83%
|
|=================================================================================================== | 84%
|
|==================================================================================================== | 84%
|
|===================================================================================================== | 85%
|
|====================================================================================================== | 85%
|
|====================================================================================================== | 86%
|
|======================================================================================================= | 86%
|
|======================================================================================================= | 87%
|
|======================================================================================================== | 87%
|
|======================================================================================================== | 88%
|
|========================================================================================================= | 88%
|
|========================================================================================================= | 89%
|
|========================================================================================================== | 89%
|
|=========================================================================================================== | 90%
|
|============================================================================================================ | 90%
|
|============================================================================================================ | 91%
|
|============================================================================================================= | 91%
|
|============================================================================================================= | 92%
|
|============================================================================================================== | 92%
|
|============================================================================================================== | 93%
|
|=============================================================================================================== | 93%
|
|=============================================================================================================== | 94%
|
|================================================================================================================ | 94%
|
|================================================================================================================= | 95%
|
|================================================================================================================== | 95%
|
|================================================================================================================== | 96%
|
|=================================================================================================================== | 96%
|
|=================================================================================================================== | 97%
|
|==================================================================================================================== | 97%
|
|==================================================================================================================== | 98%
|
|===================================================================================================================== | 98%
|
|===================================================================================================================== | 99%
|
|====================================================================================================================== | 99%
|
|====================================================================================================================== | 100%
|
|=======================================================================================================================| 100%
undergrad_pop_MT %>%
ggplot() +
geom_sf(aes(fill = estimate), color = NA) +
coord_sf(datum = NA) +
theme_minimal() +
scale_fill_viridis_c() +
labs(title = "UnderGrad Student Population in Montana by County")
grad_pop_MT <- get_acs(geography = "county",
state = "MT",
variables = "B14007G_018",
geometry = TRUE)
Getting data from the 2015-2019 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using FIPS code '30' for state 'MT'
grad_pop_MT %>%
ggplot() +
geom_sf(aes(fill = estimate), color = NA) +
coord_sf(datum = NA) +
theme_minimal() +
scale_fill_viridis_c() +
labs(title = "Grad Student Population in Montana by County")
Both of the maps above indicate that Missoula County has the most grads and undergrads. The University of Montana is located in Missoula which is in Missoula County.
Next, I searched for words related to binge drinking. ‘Alcohol’ came to mind first however, it did not seem specific enough. ‘College binge drinking’ did not have enough hits, which was surprising, and ‘frat parties’ did not have many more than that, which was even more surprising! College alcohol came back with quite a few more hits than the others.
alcohol <- trendy("alcohol",
geo = "US",
from = "2019-01-01", to = "2020-01-01")
alcohol_states <- alcohol %>%
get_interest_region()
alcohol_states
NA
collegebinging <- trendy("college binge drinking",
geo = "US",
from = "2019-01-01", to = "2020-01-01")
collegebinging_states <- collegebinging %>%
get_interest_region()
collegebinging_states
NA
frats <- trendy("frat parties",
geo = "US",
from = "2019-01-01", to = "2020-01-01")
frats_states <- frats %>%
get_interest_region()
frats_states
NA
college_alcohol <- trendy("college alcohol",
geo = "US",
from = "2019-01-01", to = "2020-01-01")
college_alcohol_states <- college_alcohol %>%
get_interest_region()
college_alcohol_states
NA
states %>%
rename(location = NAME) %>%
inner_join(college_alcohol_states)
Joining, by = "location"
Simple feature collection with 51 features and 9 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -2100000 ymin: -2500000 xmax: 2516374 ymax: 732103.3
CRS: +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs
First 10 features:
GEOID location variable estimate moe hits keyword geo gprop geometry
1 04 Arizona B01003_001 7050299 NA 34 college alcohol US web MULTIPOLYGON (((-1111066 -8...
2 05 Arkansas B01003_001 2999370 NA 24 college alcohol US web MULTIPOLYGON (((557903.1 -1...
3 06 California B01003_001 39283497 NA 49 college alcohol US web MULTIPOLYGON (((-1853480 -9...
4 08 Colorado B01003_001 5610349 NA 23 college alcohol US web MULTIPOLYGON (((-613452.9 -...
5 09 Connecticut B01003_001 3575074 NA 100 college alcohol US web MULTIPOLYGON (((2226838 519...
6 11 District of Columbia B01003_001 692683 NA NA college alcohol US web MULTIPOLYGON (((1960720 -41...
7 13 Georgia B01003_001 10403847 NA 24 college alcohol US web MULTIPOLYGON (((1379893 -98...
8 17 Illinois B01003_001 12770631 NA 23 college alcohol US web MULTIPOLYGON (((868942.5 -2...
9 18 Indiana B01003_001 6665703 NA 32 college alcohol US web MULTIPOLYGON (((1279733 -39...
10 22 Louisiana B01003_001 4664362 NA 25 college alcohol US web MULTIPOLYGON (((1080885 -16...
undergrad_leaflet <- get_acs(geography = "state", # gets state by state data
variables = "B14007G_017", # this is state undergrads
geometry = TRUE) # gets geometry (the maps)
Getting data from the 2015-2019 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
|
| | 0%
|
|= | 1%
|
|== | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|===== | 4%
|
|====== | 5%
|
|======= | 6%
|
|======== | 6%
|
|======== | 7%
|
|========= | 8%
|
|========== | 8%
|
|=========== | 9%
|
|=========== | 10%
|
|============ | 10%
|
|============= | 11%
|
|============== | 12%
|
|=============== | 12%
|
|=============== | 13%
|
|================ | 13%
|
|================ | 14%
|
|================= | 14%
|
|================== | 15%
|
|================== | 16%
|
|=================== | 16%
|
|==================== | 17%
|
|===================== | 18%
|
|====================== | 18%
|
|====================== | 19%
|
|======================= | 19%
|
|======================= | 20%
|
|======================== | 20%
|
|========================= | 21%
|
|========================== | 21%
|
|========================== | 22%
|
|=========================== | 23%
|
|============================ | 24%
|
|============================== | 25%
|
|=============================== | 26%
|
|================================ | 27%
|
|================================= | 28%
|
|================================== | 29%
|
|=================================== | 29%
|
|=================================== | 30%
|
|==================================== | 30%
|
|==================================== | 31%
|
|===================================== | 31%
|
|====================================== | 32%
|
|======================================= | 33%
|
|======================================== | 33%
|
|======================================== | 34%
|
|========================================= | 34%
|
|========================================= | 35%
|
|========================================== | 35%
|
|========================================== | 36%
|
|=========================================== | 36%
|
|=========================================== | 37%
|
|============================================ | 37%
|
|============================================= | 38%
|
|============================================== | 39%
|
|=============================================== | 39%
|
|=============================================== | 40%
|
|================================================ | 40%
|
|================================================ | 41%
|
|================================================= | 41%
|
|================================================== | 42%
|
|=================================================== | 42%
|
|=================================================== | 43%
|
|==================================================== | 43%
|
|==================================================== | 44%
|
|===================================================== | 44%
|
|===================================================== | 45%
|
|====================================================== | 45%
|
|======================================================= | 46%
|
|======================================================== | 47%
|
|========================================================= | 48%
|
|========================================================== | 48%
|
|========================================================== | 49%
|
|=========================================================== | 49%
|
|=========================================================== | 50%
|
|============================================================ | 50%
|
|============================================================ | 51%
|
|============================================================= | 51%
|
|============================================================== | 52%
|
|=============================================================== | 53%
|
|================================================================ | 53%
|
|================================================================ | 54%
|
|================================================================= | 54%
|
|================================================================= | 55%
|
|================================================================== | 55%
|
|================================================================== | 56%
|
|=================================================================== | 56%
|
|=================================================================== | 57%
|
|==================================================================== | 57%
|
|===================================================================== | 58%
|
|====================================================================== | 59%
|
|======================================================================= | 59%
|
|======================================================================= | 60%
|
|======================================================================== | 60%
|
|======================================================================== | 61%
|
|========================================================================= | 61%
|
|========================================================================== | 62%
|
|========================================================================== | 63%
|
|=========================================================================== | 63%
|
|============================================================================ | 64%
|
|============================================================================= | 65%
|
|============================================================================== | 65%
|
|============================================================================== | 66%
|
|=============================================================================== | 66%
|
|================================================================================ | 67%
|
|================================================================================= | 68%
|
|================================================================================== | 69%
|
|=================================================================================== | 70%
|
|==================================================================================== | 70%
|
|==================================================================================== | 71%
|
|===================================================================================== | 71%
|
|===================================================================================== | 72%
|
|====================================================================================== | 72%
|
|======================================================================================= | 73%
|
|======================================================================================== | 74%
|
|========================================================================================= | 74%
|
|========================================================================================= | 75%
|
|========================================================================================== | 76%
|
|=========================================================================================== | 76%
|
|=========================================================================================== | 77%
|
|============================================================================================ | 77%
|
|============================================================================================ | 78%
|
|============================================================================================= | 78%
|
|============================================================================================== | 79%
|
|=============================================================================================== | 80%
|
|================================================================================================ | 80%
|
|================================================================================================ | 81%
|
|================================================================================================= | 82%
|
|================================================================================================== | 82%
|
|=================================================================================================== | 83%
|
|=================================================================================================== | 84%
|
|==================================================================================================== | 84%
|
|===================================================================================================== | 85%
|
|====================================================================================================== | 86%
|
|======================================================================================================= | 86%
|
|======================================================================================================= | 87%
|
|======================================================================================================== | 87%
|
|========================================================================================================= | 88%
|
|========================================================================================================== | 89%
|
|=========================================================================================================== | 90%
|
|============================================================================================================ | 91%
|
|============================================================================================================== | 92%
|
|=============================================================================================================== | 93%
|
|================================================================================================================ | 94%
|
|================================================================================================================= | 95%
|
|================================================================================================================== | 96%
|
|=================================================================================================================== | 96%
|
|=================================================================================================================== | 97%
|
|==================================================================================================================== | 97%
|
|==================================================================================================================== | 98%
|
|===================================================================================================================== | 98%
|
|===================================================================================================================== | 99%
|
|====================================================================================================================== | 99%
|
|=======================================================================================================================| 100%
# shift_geo = T # shifts Hawaii and Alaska
grad_leaflet <- get_acs(geography = "state", # gets state by state data
variables = "B14007G_018", # this is state grads
geometry = TRUE) # gets geometry (the maps)
Getting data from the 2015-2019 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
# shift_geo = T # shifts Hawaii and Alaska
Binge_drinking_percent <- read_csv("Binge_drinking_percent.csv")
-- Column specification ---------------------------------------------------------------------------------------------------------
cols(
State = col_character(),
Percentage = col_double()
)
glimpse(Binge_drinking_percent)
Rows: 51
Columns: 2
$ State <chr> "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", ~
$ Percentage <dbl> 12.2, 20.0, 15.0, 15.2, 16.7, 18.1, 18.3, 15.8, 24.4, 17.2, 15.8, 19.8, 14.8, 20.8, 16.6, 21.3, 16.5, 16.1, ~
glimpse(college_alcohol_states)
Rows: 51
Columns: 5
$ location <chr> "Connecticut", "Pennsylvania", "Massachusetts", "Alabama", "Maryland", "Minnesota", "Oklahoma", "California", ~
$ hits <int> 100, 65, 58, 57, 55, 53, 50, 49, 49, 48, 47, 46, 45, 43, 43, 41, 40, 39, 38, 37, 36, 36, 35, 34, 34, 34, 33, 3~
$ keyword <chr> "college alcohol", "college alcohol", "college alcohol", "college alcohol", "college alcohol", "college alcoho~
$ geo <chr> "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "U~
$ gprop <chr> "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web"~
Now a look at how these two search terms relate to the binge drinking percentage of the states. The following map shows the binge drinking percentage by state.
college_colors <- colorNumeric(palette = "viridis", domain = college_alcohol_data$Percentage)
undergrad_leaflet %>%
rename(location = NAME) %>%
inner_join(college_alcohol_data) %>%
leaflet() %>%
addTiles() %>%
addPolygons(weight = 1,
fillColor = ~college_colors(Percentage),
label = ~paste0(location, ", Binge Drinking by Percentage by State = ", Percentage),
highlight = highlightOptions(weight = 2)) %>%
setView(-95, 40, zoom = 4) %>%
addLegend(pal = college_colors, values = ~Percentage)
Joining, by = "location"
sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
Need '+proj=longlat +datum=WGS84'
In the next map, we will see Google Search hits for college alcohol by state.
college_colors <- colorNumeric(palette = "viridis", domain = college_alcohol_data$hits)
undergrad_leaflet %>%
rename(location = NAME) %>%
inner_join(college_alcohol_data) %>%
leaflet() %>%
addTiles() %>%
addPolygons(weight = 1,
fillColor = ~college_colors(hits),
label = ~paste0(location, ", College Alcohol Hits from Google Search = ", hits),
highlight = highlightOptions(weight = 2)) %>%
setView(-95, 40, zoom = 4) %>%
addLegend(pal = college_colors, values = ~hits)
Joining, by = "location"
sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
Need '+proj=longlat +datum=WGS84'
Next we will see if there is a correlation between college alcohol and the binge drinking percentage.
college_alcohol_data <- college_alcohol_states %>%
mutate(State = state2abbr(location)) %>%
inner_join(Binge_drinking_percent)
college_alcohol_states %>%
mutate(State = state2abbr(location)) %>%
inner_join(Binge_drinking_percent)
college_model <- lm(Percentage ~ hits, data = college_alcohol_data)
glance(college_model)
tidy(college_model)
sqrt(.1457)
[1] 0.3817067
The following line graph shows a good correlation between college alcohol search hits and the binge drinking percentage by state, as the p-value also suggests.
college_alcohol_data %>%
drop_na() %>%
plot_ly(x = ~hits,
y = ~Percentage,
hoverinfo = "text",
text = ~paste("State: ", location, "<br>", "'College Alcohol' search rate: ", hits, "<br>", "Percentage: ", Percentage)) %>%
add_markers(showlegend = F) %>%
add_lines(y = ~fitted(college_model)) %>%
layout(title = "Relationship between google searches for 'College Alcohol' and Binge Drinking Rates, by State",
xaxis = list(title = "Google search volume for 'College Alcohol'"),
yaxis = list(title = "State Binge Drinking Rate, per capita"))
NA
NA
Now we will look at Google search hits for frat parties as compared to the binge drinking percentage to see if there is a good correlation there as well.
states %>%
rename(location = NAME) %>%
inner_join(frats_states)
Joining, by = "location"
Simple feature collection with 51 features and 9 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -2100000 ymin: -2500000 xmax: 2516374 ymax: 732103.3
CRS: +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs
First 10 features:
GEOID location variable estimate moe hits keyword geo gprop geometry
1 04 Arizona B01003_001 7050299 NA NA frat parties US web MULTIPOLYGON (((-1111066 -8...
2 05 Arkansas B01003_001 2999370 NA NA frat parties US web MULTIPOLYGON (((557903.1 -1...
3 06 California B01003_001 39283497 NA 47 frat parties US web MULTIPOLYGON (((-1853480 -9...
4 08 Colorado B01003_001 5610349 NA NA frat parties US web MULTIPOLYGON (((-613452.9 -...
5 09 Connecticut B01003_001 3575074 NA NA frat parties US web MULTIPOLYGON (((2226838 519...
6 11 District of Columbia B01003_001 692683 NA NA frat parties US web MULTIPOLYGON (((1960720 -41...
7 13 Georgia B01003_001 10403847 NA NA frat parties US web MULTIPOLYGON (((1379893 -98...
8 17 Illinois B01003_001 12770631 NA 63 frat parties US web MULTIPOLYGON (((868942.5 -2...
9 18 Indiana B01003_001 6665703 NA NA frat parties US web MULTIPOLYGON (((1279733 -39...
10 22 Louisiana B01003_001 4664362 NA NA frat parties US web MULTIPOLYGON (((1080885 -16...
glimpse(Binge_drinking_percent)
Rows: 51
Columns: 2
$ State <chr> "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME~
$ Percentage <dbl> 12.2, 20.0, 15.0, 15.2, 16.7, 18.1, 18.3, 15.8, 24.4, 17.2, 15.8, 19.8, 14.8, 20.8, 16.6, 21.3, 16.5, 16.1, 18.0, 20.~
glimpse(frats_states)
Rows: 51
Columns: 5
$ location <chr> "New Jersey", "New York", "Pennsylvania", "Virginia", "Illinois", "North Carolina", "Massachusetts", "Florida", "Califo~
$ hits <int> 100, 82, 70, 69, 63, 62, 55, 51, 47, 7, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,~
$ keyword <chr> "frat parties", "frat parties", "frat parties", "frat parties", "frat parties", "frat parties", "frat parties", "frat p~
$ geo <chr> "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US", "US",~
$ gprop <chr> "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", "web", ~
frats_data <- frats_states %>%
mutate(State = state2abbr(location)) %>%
inner_join(Binge_drinking_percent)
Joining, by = "State"
frats_colors <- colorNumeric(palette = "viridis", domain = frats_data$hits)
undergrad_leaflet %>%
rename(location = NAME) %>%
inner_join(frats_data) %>%
leaflet() %>%
addTiles() %>%
addPolygons(weight = 1,
fillColor = ~frats_colors(hits),
label = ~paste0(location, ", Frat Parties Hits from Google Search = ", hits),
highlight = highlightOptions(weight = 2)) %>%
setView(-95, 40, zoom = 4) %>%
addLegend(pal = frats_colors, values = ~hits)
Joining, by = "location"
sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
Need '+proj=longlat +datum=WGS84'
The above map shows that there were not many hits for ‘frat parties’ on Google Search.
frats_model <- lm(Percentage ~ hits, data = frats_data)
glance(frats_model)
tidy(frats_model)
sqrt(.0406)
[1] 0.2014944
frats_data %>%
drop_na() %>%
plot_ly(x = ~hits,
y = ~Percentage,
hoverinfo = "text",
text = ~paste("State: ", location, "<br>", "'Frat Parties' search rate: ", hits, "<br>", "Percentage: ", Percentage)) %>%
add_markers(showlegend = F) %>%
add_lines(y = ~fitted(frats_model)) %>%
layout(title = "Relationship between google searches for 'Frat Parties' and Binge Drinking Rates, by State",
xaxis = list(title = "Google search volume for 'Frat Parties'"),
yaxis = list(title = "State Binge Drinking Rate, per capita"))
NA
NA
However, the p-values for ‘frat parties’ show a statistically significant relationship to binge drinking percentage by state as well, as shown in the line graph above.