acs12 | R Documentation |
Results from the US Census American Community Survey, 2012.
acs12
A data frame with 2000 observations on the following 13 variables.
Annual income.
Employment status.
Hours worked per week.
Race.
Age, in years.
Gender.
Whether the person is a U.S. citizen.
Travel time to work, in minutes.
Language spoken at home.
Whether the person is married.
Education level.
Whether the person is disabled.
The quarter of the year that the person was born,
e.g. Jan thru Mar
.
https://www.census.gov/programs-surveys/acs
library(dplyr)
library(ggplot2)
library(broom)
# employed only
acs12_emp <- acs12 |>
filter(
age >= 30, age <= 60,
employment == "employed",
income > 0
)
# linear model
ggplot(acs12_emp, mapping = aes(x = age, y = income)) +
geom_point() +
geom_smooth(method = "lm")
lm(income ~ age, data = acs12_emp) |>
tidy()
# log-transormed model
ggplot(acs12_emp, mapping = aes(x = age, y = log(income))) +
geom_point() +
geom_smooth(method = "lm")
lm(log(income) ~ age, data = acs12_emp) |>
tidy()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.