Skip to content

Instantly share code, notes, and snippets.

@elinw
Forked from naomispence/chs2019_2020
Created November 5, 2022 02:34
Show Gist options
  • Save elinw/4920ba3707172a04457aeae8859008ae to your computer and use it in GitHub Desktop.
Save elinw/4920ba3707172a04457aeae8859008ae to your computer and use it in GitHub Desktop.
library(haven)
chs2019_public <- read_sas("~/Downloads/chs2019_public.sas7bdat",
NULL)
library(Hmisc)
library(descr)
library(haven)
chs2020_public <- read_sas("~/Downloads/chs2020_public.sas7bdat",
NULL)
chs2020small = subset(chs2020_public, select = c("survey", "qxvers", "mood1" , "mood2"))
chs2019small = subset(chs2019_public, select = c("survey", "qxvers", "mood1" , "mood2"))
chs2019_2020 <-rbind(chs2020small, chs2019small)
freq(chs2019_2020$survey)
ggplot(data = chs2019_2020, aes(x = mood1)) + geom_histogram(color="blue", fill="white", binwidth =1, aes(y=(..count../sum(..count..))*100)) +
ggtitle("Figure #. Distribution of DESCRIBE YOUR VARIABLE")+
labs(y="Percent", x="LABEL FOR YOUR VARIABLE VALUES")
ggplot(data=chs2019_2020)+
stat_summary(aes(x=survey, y=mood1), fun.y=mean, geom="bar")+
ggtitle("Descriptive Title Here")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment