── 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.5.1 ✔ 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(primer.data)library(scales)
Attaching package: 'scales'
The following object is masked from 'package:purrr':
discard
The following object is masked from 'package:readr':
col_factor
Rows: 2242 Columns: 3
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): tract, race
dbl (1): med_income
ℹ 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.
# Create the beeswarm plot with viridis color scalenyc_tracts|>ggplot(mapping=aes(x = med_income, y = race, color = med_income)) +geom_quasirandom(alpha =0.7, size =2) +scale_x_continuous(labels = scales::dollar_format()) +scale_color_viridis(option ="D", direction =1, name ="Median Household Income") +theme_minimal() +labs(title ="Household income distribution by largest racial/ethnic group",subtitle ="Census tracts, New York City",x ="Median household income",y ="Largest group in Census tract",caption ="Data source: 2016-2020 ACS" ) +theme(plot.title =element_text(size =20, face ="bold"),plot.subtitle =element_text(size =14),plot.caption =element_text(size =10),legend.position ="none" )
Orientation inferred to be along y-axis; override with
`position_quasirandom(orientation = 'x')`