Created
February 7, 2018 23:07
-
-
Save thoughtfulbloke/7dcc08f26fc6f8df3865de4e8d53a180 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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