<- read_csv(
nyc_dog_license 'https://bcdanl.github.io/data/nyc_dog_license.csv')
Homework 3
ggplot
Visualization; Maps; Quarto Blogging
Direction
Please submit your Quarto Document for Part 1 in Homework 2 to Brightspace with the name below:
danl-310-hw3-LASTNAME-FIRSTNAME.qmd
( e.g.,danl-310-hw3-choe-byeonghak.qmd
)
The due is April 5, 2025, 5:00 P.M.
Please send Byeong-Hak an email (
bchoe@geneseo.edu
) if you have any questions.
Part 1. Map visualization
Question 1
The following data set is for Question 1:
<- read_csv(
nyc_zips_coord 'https://bcdanl.github.io/data/nyc_zips_coord.csv')
<- read_csv(
nyc_zips_df 'https://bcdanl.github.io/data/nyc_zips_df.csv')
Q1a
Replicate the following ggplot.
- You should calculate the proportion of
Pit Bull (or Mix)
for each zip code. - You should join data.frames properly.
- Choose the color palette from the
viridis
scales - Use
coord_map(projection = "albers", lat0 = 39, lat1 = 45)
. - To insert the image, use the following
annotate()
:
- You should calculate the proportion of
# install.packages("ggtext")
library(ggtext)
annotate("richtext",
x = ,
y = ,
label = "<img src='https://bcdanl.github.io/lec_figs/pitbull.png' width='750'/>",
fill = NA,
color = NA)
- Note that the size of ggplot figure is 6.18 (width) x 6.84 (height)
```{.r}
#| fig-width: 6.18
#| fig-height: 6.84
# YOUR CODE IS HERE
```
Q1b
- Which
zip_code
has the highest proportion ofPit Bull (or Mix)
?
Question 2
The following data is for Question 2:
<- read_csv(
election_panel 'https://bcdanl.github.io/data/election_panel.csv')
- Replicate the following map.
- Do not use
coord_map(projection = "albers", lat0 = 39, lat1 = 45)
.
- Do not use
Part 2. Quarto Blogging
- Use the following set of data.frames for Quarto Blogging:
<- read_csv(
nyc_dog_license 'https://bcdanl.github.io/data/nyc_dog_license.csv')
<- read_csv(
nyc_zips_coord 'https://bcdanl.github.io/data/nyc_zips_coord.csv')
<- read_csv(
nyc_zips_df 'https://bcdanl.github.io/data/nyc_zips_df.csv')