library(readr)
## Warning: package 'readr' was built under R version 4.2.1
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.1
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ dplyr 1.0.9
## ✔ tibble 3.1.8 ✔ stringr 1.4.0
## ✔ tidyr 1.2.0 ✔ forcats 0.5.2
## ✔ purrr 0.3.4
## Warning: package 'ggplot2' was built under R version 4.2.1
## Warning: package 'tibble' was built under R version 4.2.1
## Warning: package 'dplyr' was built under R version 4.2.1
## Warning: package 'forcats' was built under R version 4.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(sf)
## Warning: package 'sf' was built under R version 4.2.1
## Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
library(tmap)
## Warning: package 'tmap' was built under R version 4.2.1
library(leaflet)
library(here)
## Warning: package 'here' was built under R version 4.2.1
## here() starts at D:/Georgia Tech/Spec topic_/MIni_assignment 4
library(tidycensus)
## Warning: package 'tidycensus' was built under R version 4.2.1
Yelp <- read.csv("coffee.csv", head = TRUE)
bxplot <- ggplot(data = Yelp) +
geom_boxplot(aes(x=avg_rating, y=hhincome),
color="black",fill="white")
library(plotly)
## Warning: package 'plotly' was built under R version 4.2.1
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(bxplot)
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
bcplt2 <- ggplot(data = Yelp) +
geom_boxplot(aes(x = avg_rating, y=hhincome),
color = "black", fill = "white") +
facet_wrap(~county) +
scale_fill_brewer(palette = "Blues")
plotly::ggplotly(bcplt2)
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
mycols <- c('pct_pov_log' = "% residents under poverty",
'hhincome' = "Median Annual Househol Income",
'pct_white' = "Percent White Resident",
'race.tot' = "Total Population")
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.2.1
Yelp %>%
pivot_longer(cols = names(mycols), names_to = "variable", values_to = "value") %>%
ggplot(data= ., mapping = aes(x= review_count_log, y = value))+
geom_point(aes(color = county))+
geom_smooth(aes(color= county), method = "lm", se = F)+
ggpubr::stat_cor(method = "pearson") +
facet_wrap(~variable, scales = "free_y", labeller= as_labeller(mycols)) +
theme_light()
## `geom_smooth()` using formula 'y ~ x'
