Skip to content

Instantly share code, notes, and snippets.

@elinw
Forked from naomispence/YRBS
Last active November 5, 2022 01:35
Show Gist options
  • Save elinw/a3f579cf0ed238cb443cdcf175a7c1de to your computer and use it in GitHub Desktop.
Save elinw/a3f579cf0ed238cb443cdcf175a7c1de to your computer and use it in GitHub Desktop.
library(aws.s3)
Sys.setenv("AWS_ACCESS_KEY_ID" = "XXXX",
"AWS_SECRET_ACCESS_KEY" = "XXXX",
"AWS_DEFAULT_REGION" = "us-west-2")
s3load('nycyrbs.RData', bucket = 'XXXX')
nycyrbs <- subset(nycyrbs, select = c(q33, q34, q35, grade))
nycyrbs[nycyrbs==""]<-NA
skimr::skim(nycyrbs)
library(Hmisc)
library(descr)
label(nycyrbs$q34) <-"Vape Usage"
label(nycyrbs$q35) <-"Recent Vape Usage"
freq(nycyrbs$q34)
freq(nycyrbs$q35)
label(nycyrbs$q35) <-"Recent Vape Usage"
# I have to load dataset first
# Use lowercase nycyrbs data set, not capital for consistency
label(nycyrbs$grade) <-"Grade Level"
freq(nycyrbs$grade)
freq(nycyrbs$q33)
freq(nycyrbs$q34)
ggtitle("Figure #. Distribution of DESCRIBE YOUR VARIABLE")+
labs(y="Percent", x="LABEL FOR YOUR VARIABLE VALUES")
ggplot(data = nycyrbs, aes(x = grade)) + geom_histogram(color="blue", fill="white", aes(y=(..count../sum(..count..))*100)) +
ggtitle("Figure #. Distribution of DESCRIBE YOUR VARIABLE")+
labs(y="Percent", x="LABEL FOR YOUR VARIABLE VALUES")
summary(nycyrbs$grade)
sd(nycyrbs$grade, na.rm=T)
# save(nycyrbs, file = "nycyrbs.RData")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment