Skip to content

Instantly share code, notes, and snippets.

@naomispence
Created November 2, 2022 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save naomispence/fa1121e8231397ac5555ad343a1aa4d3 to your computer and use it in GitHub Desktop.
Save naomispence/fa1121e8231397ac5555ad343a1aa4d3 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