Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
library(atus)
library(dplyr)
library(ggplot2)
library(ggridges)
library(viridis)
data("atusact")
data("atuscps")
data("atusresp")
actions <- c("Relaxing&Thinking", "Tobacco&Drugs", "TV&Movies", "Relgious TV",
"Listen to Radio", "Listen/Play music", "Games", "Computer non-games",
"Arts&Crafts", "Collecting", "Hobbies", "Reading", "Writing")
#from the atuact help 120300-120400 is receational activity
sports <- atusact %>% filter(tiercode > 120300, tiercode < 120350) %>%
mutate(activity = actions[tiercode-120300]) %>% select(tucaseid, activity)
atuscps %>%
select(tucaseid, age, sex) %>% inner_join(sports) %>%
ggplot(aes(x=age, y= activity,fill=floor(..x../10))) +
geom_density_ridges_gradient(rel_min_height = 0.01, colour="white") +
xlab("age of particpants") + xlim(15,86) +
scale_fill_viridis() + theme_minimal() + guides(fill=FALSE) +
ggtitle("Age distributions of recreational activity participants (source ATUS)")+
facet_wrap(~ sex, ncol=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.