Skip to content

Instantly share code, notes, and snippets.

@naomispence
Created November 2, 2022 16:03
Show Gist options
  • Save naomispence/7b24ed7dcf1afb39fd8de90459bfeedf to your computer and use it in GitHub Desktop.
Save naomispence/7b24ed7dcf1afb39fd8de90459bfeedf to your computer and use it in GitHub Desktop.
load("nycyrbs.RData")
nycyrbs1<-subset(nycyrbs, select = c(q33, q34, q35, grade))
#rm(nycyrbs)
nycyrbs[nycyrbs==""]<-NA
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)
ggplot(data = nycyrbs1, aes(x = q33)) + geom_bar(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")
ggplot(data = nycyrbs1, 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(nycyrbs1$grade)
sd(nycyrbs1$grade, na.rm=T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment