I have this code here but need to make the graph below:
df.census <- census
marital.status <- census$marital_status
race <- census$race_general
ggplot(dat = df.census, mapping = aes(x = marital.status, y = race))
geom_point(size=marital.status) geom_line()
CodePudding user response:
You can try this way.
census %>%
group_by(sex, race_general, marital_status) %>%
summarise(count = n()) %>%
ggplot(aes(x = sex, y = race_general, color = sex, size = count))
geom_point() facet_wrap(.~marital_status)
CodePudding user response:
Like this?
library(tidyverse)
#install.packages("openintro")
library(openintro)
#> Loading required package: airports
#> Loading required package: cherryblossom
#> Loading required package: usdata
census %>%
ggplot(aes(x = sex, y = race_general, color = sex))
geom_count()
facet_wrap(~marital_status)
theme_linedraw(base_size = 14)
scale_size_area(name = "Count")
scale_x_discrete(name = "", breaks = NULL)
Created on 2021-10-08 by the reprex package (v2.0.1)