# Loading packages.
library(devtools)
# install_github('arilamstein/choroplethrZip@v1.4.0')
library(choroplethrZip)
library(dplyr)
library(ggplot2)
library(car)
library(data.table)
# Define default colors of GreatNonprofits for visualization.
ciBlue <- "#11A7A5"
ciOrange <- "#F7931E"
##############
# SJDD Panel #
##############
# Import the sjdd dataset.
sjdd <- read.csv("SJC_DDsurvey.csv")
# Substitute "" and NULL entries in the dataset with "NA"
sjdd[sjdd==""] <- NA
sjdd[sjdd=="NULL"] <- NA
# Filter the dataset by removing all the "Bad phone number" observations.
sjdd_good <- subset(sjdd, is.na(reason_excluded_txt))
########################################################################
# Update sjdd_good with respondents with no home internet subscription #
########################################################################
# Import the sjdd_nhi dataset.
sjdd_nhi <- read.csv("Cleaned_Nointernet.csv")
# Substitute "" and NULL entries in the dataset with "NA".
sjdd_nhi[sjdd_nhi==""] <- NA
sjdd_nhi[sjdd_nhi=="NULL"] <- NA
# Update columns in sjdd with the same columns present in sjdd_nhi.
cols <- setdiff(colnames(sjdd_nhi), "phone_number")
setDT(sjdd_good)[setDT(sjdd_nhi), (cols) := mget(paste0('i.', cols)), on = "phone_number"]
# Creating the final dataframe for barchart.
sjdd_language <- sjdd_good %>%
group_by(lang_cat) %>%
summarise(n = n())
# Creating barchart for Language of Respondent.
ggplot(aes(x = lang_cat, y = n), data = sjdd_language) +
geom_bar(stat = "identity",color = I('black'), fill = I(ciBlue), width = 0.5) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
scale_y_continuous(breaks = seq(0,max(sjdd_language$n),50), limits = c(0,max(sjdd_language$n))) +
theme_bw()+
xlab("Language Chosen") +
ylab("Number of Respondents") +
ggtitle('Language of Respondent') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = ciOrange,
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))
# Removing non-integer values.
sjdd_good <- sjdd_good[!is.na(as.numeric(
as.character(sjdd_good$num_child_txt))),]
# Converting the type of num_child_txt to numeric.
sjdd_good$num_child_txt <- as.numeric(
as.character(sjdd_good$num_child_txt))
# Creating the final dataframe for barchart.
sjdd_K12 <- sjdd_good %>%
group_by(num_child_txt) %>%
summarise(n = n())
# Create barchart for Number of Children in K-12 School.
ggplot(aes(x = num_child_txt, y = n), data = sjdd_K12) +
geom_histogram(stat = "identity", binwidth = 1, color = I('black'), fill = I(ciBlue)) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw()+
scale_x_continuous(limits = c(0, 9), breaks = seq(0, 9, by = 1)) +
scale_y_continuous(limits = c(0, max(sjdd_K12$n)), breaks = seq(0, max(sjdd_K12$n), by = 50)) +
xlab("Number of Children in K-12 School") +
ylab("Number of Respondents") +
ggtitle('Number of Children in K-12 School') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = ciOrange,
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))
# Creating the final dataframe for barchart.
sjdd_hasint <- sjdd_good %>%
group_by(homeInternet_cat) %>%
summarise(n = n())
# Create barchart for Do Respondents have Internet access?.
ggplot(aes(x = homeInternet_cat, y = n), data = sjdd_hasint) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.5) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
scale_y_continuous(breaks = seq(0,max(sjdd_hasint$n),100), limits = c(0,max(sjdd_hasint$n))) +
theme_bw() +
xlab("Has Internet access at Home") +
ylab("Number of Respondents") +
ggtitle('Do Respondents have Internet access?') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = ciOrange,
face = "bold",
size = 21,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14)) +
scale_x_discrete(labels = c("N" = "No", "Y" = "Yes"))
# Subset sjdd_good to get a dataset containing only respondents with internet access
sjdd_good_yesint <- subset(sjdd_good, sjdd_good$homeInternet_cat == "Y" & sjdd_good$homeInternet_cat !="" )
# Creating the final dataframe for barchart.
sjdd_topdevice <- sjdd_good_yesint %>%
group_by(child_device_most_used_cat) %>%
summarise(n = n())
# Create barchart for Most used Device by Children to access the Internet.
ggplot(aes(x = child_device_most_used_cat, y = n),
data = subset(sjdd_topdevice, child_device_most_used_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
scale_y_continuous(breaks = seq(0,450,50), limits = c(0,450)) +
theme_bw()+
xlab("Most Used Device by Children") +
ylab("Number of Respondents") +
ggtitle('Most used Device by Children to access the Internet') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = ciOrange,
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Creating the final dataframe for barchart.
sjdd_2ndtopdevice <- sjdd_good_yesint %>%
group_by(child_device_2nd_used_cat) %>%
summarise(n = n())
# Create barchart for 2nd Most used Device by Children to access the Internet.
ggplot(aes(x = child_device_2nd_used_cat, y = n),
data = subset(sjdd_2ndtopdevice, child_device_2nd_used_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
scale_y_continuous(breaks = seq(0,260,50), limits = c(0,260)) +
theme_bw() +
xlab("2nd Most Used Device by Children") +
ylab("# of Respondents") +
ggtitle(' 2nd Most used Device by Children to access the Internet') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 13,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Creating the final dataframe for barchart.
sjdd_childhwdevice <- sjdd_good_yesint %>%
group_by(child_homework_device_cat) %>%
summarise(n = n())
# Create barchart for Device used by Children to do Homework.
ggplot(aes(x = child_homework_device_cat, y = n),
data = subset(sjdd_childhwdevice, child_homework_device_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,160,50), limits = c(0,160)) +
xlab("Device used by Children for Homework") +
ylab("Number of Respondents") +
ggtitle('Device used by Children to do Homework') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Creating the final dataframe for barchart.
sjdd_childworkdevice <- sjdd_good_yesint %>%
group_by(child_device_work_cat) %>%
summarise(n = n())
sjdd_childworkdevice$child_device_work_cat[sjdd_childworkdevice$child_device_work_cat == "Other"] <- NA
# Create barchart for Quality of Children's Device work for Homework.
ggplot(aes(x = child_device_work_cat, y = n),
data = subset(sjdd_childworkdevice, !is.na(sjdd_childworkdevice$child_device_work_cat))) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,350,50), limits = c(0,350)) +
xlab("Quality of Children's Device for Homework") +
ylab("Number of Respondents") +
ggtitle("Quality of Children's Device for Homework") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Creating the final dataframe for barchart.
sjdd_childcommpplcat <- sjdd_good_yesint %>%
group_by(child_comm_ppl_cat) %>%
summarise(n = n())
# Create barchart for Top Service for Children interacting with Friends.
ggplot(aes(x = child_comm_ppl_cat, y = n),
data = subset(sjdd_childcommpplcat, child_comm_ppl_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,200,50), limits = c(0,200)) +
xlab("Top Service for Children interacting with Friends") +
ylab("Number of Respondents") +
ggtitle("Top Service for Children interacting with Friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Assign appropriate names to random entries.
sjdd_good_yesint$child_comm_ppl_other_txt <- recode(sjdd_good_yesint$child_comm_ppl_other_txt,
"c('A','answer','B','B text','D','F', 'Other social media') = NA;
c('Instagram and Kim', 'Istagram',
'Snapchat and instagram', 'Ig', 'IG') = 'Instagram';
c('Snap chat', 'Snapchat, Instagram') = 'Snapchat';
c('Musically') ='Musical.Ly'")
sjdd_good_yesint$child_comm_ppl_other_txt[
sjdd_good_yesint$child_comm_ppl_other_txt == "Don't use any of these yet"] <- NA
# Subset dataframe and group by child_comm_ppl_other_txt
Other_comm_df <- subset(sjdd_good_yesint, !is.na(sjdd_good_yesint$child_comm_ppl_other_txt)) %>%
group_by(child_comm_ppl_other_txt) %>%
summarise(n = n())
# ggplot(data = Other_comm_df, aes(x = factor(1), n, fill = child_comm_ppl_other_txt)) +
# geom_bar(width = 1, stat = "identity") +
# geom_text(aes(y = n/10 + c(0, cumsum(n)[-length(n)]),
# label = percent(n/100))) +
# coord_polar("y", start = 0)
# Create pie chart for other Top Service for Children interacting with Friends.
slices <- Other_comm_df$n
lbls <- Other_comm_df$child_comm_ppl_other_txt
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = "")
pie(slices, labels = lbls, col = heat.colors(length(lbls)),
main = "Other Top Services for Children Interacting with Friends", col.main = "#F7931E")
### 19. 2nd Top Service for Children interacting with friends
# Creating the final dataframe for barchart.
sjdd_2ndchildcommpplcat <- sjdd_good_yesint %>%
group_by(child_2nd_comm_ppl_cat) %>%
summarise(n = n())
# Create barchart for 2nd Top Service for Children interacting with friends.
ggplot(aes(x = child_2nd_comm_ppl_cat, y = n),
data = subset(sjdd_2ndchildcommpplcat, child_2nd_comm_ppl_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,250,50), limits = c(0,250)) +
xlab("2nd Top Service for Children interacting with friends") +
ylab("Number of Respondents") +
ggtitle("2nd Top Service for Children interacting with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Assign appropriate names to random entries.
sjdd_good_yesint$child_2nd_comm_ppl_other_txt <- recode(sjdd_good_yesint$child_2nd_comm_ppl_other_txt,
"c('If','Nothing','Text','F', 'F other social media') = NA;
c('Istagram', 'Snapchat and instagram', 'Ig','IG','Instagram and messenger') = 'Instagram';
c('Snap chat', 'Nachap', 'Snapshat', 'SnapChat') = 'Snapchat';
c('MusicLy', 'Applications on phone (Musicly)')='Musical.ly';
c('Facetime')='FaceTime'")
# Creating the final dataframe for barchart.
sjdd_conbigchild <- sjdd_good_yesint %>%
group_by(con_big_child_cat) %>%
summarise(n = n())
# Create barchart for Biggest Concern about Children's Internet use.
ggplot(aes(x = con_big_child_cat, y= n),
data = subset(sjdd_conbigchild, con_big_child_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,450,50), limits = c(0,450)) +
xlab("Biggest Concern about Children's Internet use") +
ylab("Number of Respondents") +
ggtitle("Biggest Concern about Children's Internet use") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Creating the final dataframe for barchart.
sjdd_2ndconbigchild <- sjdd_good_yesint %>%
group_by(con_2nd_big_child_cat) %>%
summarise(n = n())
# Create barchart for 2nd Biggest Concern about Children's Internet use.
ggplot(aes(x = con_2nd_big_child_cat, y = n),
data = subset(sjdd_2ndconbigchild, con_2nd_big_child_cat != "")) +
geom_bar(stat = "identity", color = I('black'), fill = I(ciBlue), width = 0.7) +
geom_text(aes(label = n), position = position_dodge(width = 0.5), vjust = -0.5) +
theme_bw() +
scale_y_continuous(breaks = seq(0,300,50), limits = c(0,300)) +
xlab("2nd Biggest Concern about Children's Internet use") +
ylab("Number of Respondents") +
ggtitle("2nd Biggest Concern about Children's Internet use") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Assign appropriate names to random entries.
sjdd_good_yesint$con_2nd_big_child_other_txt <- recode(sjdd_good_yesint$con_2nd_big_child_other_txt,
"c('C', 'D', 'Bullying') = NA;
c('Identy theft')='Identity Theft';
c('Content they have access to', 'Inappropriate sites',
'They might do something their not supposed to do')='Inappropriate content';
c('Spending money')='Spending too much money online';
c('Takes away from school work','Not getting their homework done' )='Not getting homework done'")
# Subset dataframe and group by child_comm_ppl_other_txt
Other_2nd_big_con_df <- subset(sjdd_good_yesint,
!is.na(sjdd_good_yesint$con_2nd_big_child_other_txt)) %>%
group_by(con_2nd_big_child_other_txt) %>%
summarise(n = n())
# Create pie chart for other 2nd Biggest Concern about Children's Internet use
slices <- Other_2nd_big_con_df$n
lbls <- Other_2nd_big_con_df$con_2nd_big_child_other_txt
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = "")
pie(slices, labels = lbls, col = heat.colors(length(lbls)),
main = "Other 2nd Biggest Concern about Children's Internet use", col.main = "#F7931E")
# Create barchart for How Children get their Internet access for their device at home.
ggplot(aes(x = child_internet_access_home_cat),
data = subset(sjdd_good_yesint, child_internet_access_home_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Way to get Home Internet") +
ylab("# of Respondents") +
ggtitle("Way for Children to get Home Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Top Service for Parents interacting with friends.
ggplot(aes(x = pars_inter_ppl_cat),
data = subset(sjdd_good_yesint, pars_inter_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Service Parents use to interact with friends ") +
ylab("# of Respondents") +
ggtitle("Top Service for Parents interacting with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for 2nd Top Service for Parents interacting with friends.
ggplot(aes(x = pars_2nd_inter_ppl_cat),
data = subset(sjdd_good_yesint, pars_2nd_inter_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Top Service Parents use to interact with friends ") +
ylab("# of Respondents") +
ggtitle("2nd Top Service for Parents interacting with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for How Parents get their Internet access for their device at home.
ggplot(aes(x = pars_access_internet_home_cat),
data = subset(sjdd_good_yesint, pars_access_internet_home_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Way to get Home Internet") +
ylab("# of Respondents") +
ggtitle("Way for Parents to get Home Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
sjdd_good_yesint$pars_internet_work_cat[sjdd_good_yesint$pars_internet_work_cat == "Other"] <- NA
# Create barchart for How well does Parents' home Internet work.
ggplot(aes(x = pars_internet_work_cat),
data = subset(sjdd_good_yesint, pars_internet_work_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Quality of Parents' home Internet") +
ylab("# of Respondents") +
ggtitle("Quality of Parents' home Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Parents' reason for using Internet primarily on mobile device.
ggplot(aes(x = why_mobile_cat),
data = subset(sjdd_good_yesint, why_mobile_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Primary Reason for using Mobile Device for Internet") +
ylab("# of Respondents") +
ggtitle("Primary Reason for using Mobile Device for Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# What is your five-digit home zip code?
sjdd_good_yesint$zipcode_txt <- as.character(sjdd_good_yesint$zipcode_txt)
respondZipDf <- subset(sjdd_good_yesint, !is.na(sjdd_good_yesint$zipcode_txt))
respondZip <- respondZipDf %>%
group_by(zipcode_txt) %>%
summarise(value = n())
names(respondZip)[names(respondZip) == "zipcode_txt"] <- "region"
zip_choropleth(respondZip[respondZip$value>1,],
num_colors = 1,
zip_zoom = respondZip$region[respondZip$value>1],
legend = "# Response") +
scale_fill_gradient(high = "#11A7A5", low = "white")
# Create barchart for Total Combined Household Annual Income.
ggplot(aes(x = income_cat),
data = subset(sjdd_good_yesint, income_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Total Combined Household Annual Income") +
ylab("# of Respondents") +
ggtitle("Total Combined Household Annual Income") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
sjdd_good_yesint$affordable_housing_cat[sjdd_good_yesint$affordable_housing_cat == "Other"] <-NA
# Create barchart for Housing Type.
ggplot(aes(x = affordable_housing_cat),
data = subset(sjdd_good_yesint, affordable_housing_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Housing Type") +
ylab("# of Respondents") +
ggtitle("Housing Type of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Assign appropriate names to random entries.
sjdd_good_yesint$other_housing_txt <- recode(sjdd_good_yesint$other_housing_txt,
"c('a', 'A', 'Affordable housing','Answer','b','B','C','Market rate','None',
'Other housing', 'Other Housing','Room','Sfh') = NA;
c('An Apartment', 'Apartments', 'Apt', 'Departamento','Departamento de renta',
'No housing just old apartment','Rent an apartment')='Apartment';
c('Casa de renta','Lease','Regular rent', 'Regular rental','rent','Rent',
'RENT','Rent from family','Renta','Renta regular','Rental',
'Rented single family home','Renter','Renting','Rommate','We Rent A House')='Rental House';
c('Casa','Casa propia','house','Own house','House','Own home', 'Purchased house',
'Single family home','Single Family house','Own', 'Regular','Regular house',
'Regular housing')='Own a house';
c('Low income')='Low income housing';
c('Mobile','Mobile home','Mobile house')='Mobile Home';
c('Parents','Parents')='With family';
c('We have a duplex')='Duplex'")
# Subset dataframe and group by other_housing_txt
Other_housing_df <- subset(sjdd_good_yesint, !is.na(sjdd_good_yesint$other_housing_txt)) %>%
group_by(other_housing_txt) %>%
summarise(n = n())
# Create bar chart for Other Housing type.
ggplot(data = Other_housing_df, aes(x = reorder(other_housing_txt, n), y = n)) +
geom_col(show.legend = FALSE,color = I('black'), fill = I('#11A7A5')) +
ggtitle(paste("Other Housing Type of Respondents")) +
xlab("Housing Type of Respondents") +
ylab("Number of Respondents") +
coord_flip() +
geom_label(aes(label = paste0(sprintf("%1.1f",
Other_housing_df$n/sum(Other_housing_df$n)*100),"%",
sep = "\n", n),
y = -5, fill = other_housing_txt),
show.legend = FALSE,
size = 3, label.padding = unit(0.1, "lines")) +
expand_limits(y = -5) +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5))
#label = paste0(sprintf("%1.1f", Count/sum(Count)*100),"%")
# Remove non-integer values.
sjdd_good_yesint <- sjdd_good_yesint[!is.na(as.numeric(
as.character(sjdd_good_yesint$ppl_house_txt))),]
# Transform the variable ppl_house_txt to numeric
sjdd_good_yesint$ppl_house_txt <- as.numeric(
as.character(sjdd_good_yesint$ppl_house_txt))
# Create barchart for Number of People living the house.
ggplot(aes(x = ppl_house_txt), data = sjdd_good_yesint) +
geom_histogram(binwidth = 1, color = I('black'), fill = I('#11A7A5')) +
scale_x_continuous(limits = c(0, 11), breaks = seq(0, 11, by = 1)) +
theme_bw() +
xlab("Number of People living the house") +
ylab("# of Respondents") +
ggtitle("Number of People living the house") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Create barchart for Gender of Respondents.
ggplot(aes(x = gender_cat), data = sjdd_good_yesint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Gender") +
ylab("# of Respondents") +
ggtitle('Gender of Respondents') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))
# Create barchart for Ethnicity of Respondents.
ggplot(aes(x = race_cat), data = sjdd_good_yesint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Race") +
ylab("# of Respondents") +
ggtitle("Race of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Transform the variable birth_year_txt to numeric.
sjdd_good_yesint$birth_year_txt <- as.numeric(
as.character(sjdd_good_yesint$birth_year_txt))
# Categorize birth_year_txt.
sjdd_good_yesint$birth_year_txt.group <- cut(sjdd_good_yesint$birth_year_txt,
c(1900, 1910, 1920, 1930, 1940,
1950, 1960, 1970, 1980, 1990,
2000),
labels = c("1900-1910", "1911-1920",
"1921-1930", "1931-1940",
"1941-1950", "1951-1960",
"1961-1970", "1971-1980",
"1981-1990", "1991-2000"),
right = TRUE)
# Create barchart for the year born of respondents.
ggplot(aes(x = birth_year_txt.group),
data = subset(sjdd_good_yesint, !is.na(birth_year_txt.group))) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Year born of Respondents") +
ylab("# of Respondents") +
ggtitle("Year born of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
sjdd_good_yesint$future_survey_cat[is.na(sjdd_good_yesint$future_survey_cat)] <- "No"
# Create barchart for Willingness to participate in Future Survey.
ggplot(aes(x = future_survey_cat), data = sjdd_good_yesint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Willingness to participate in Future Survey") +
ylab("# of Respondents") +
ggtitle('Willingness to participate in Future Survey') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 20,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))
# Subset sjdd_good to get a dataset containing only respondents with NO internet access
sjdd_good_noint <- subset(sjdd_good, sjdd_good$homeInternet_cat == "N" & sjdd_good$homeInternet_cat !="" )
# Create barchart for Primary Benefit to Parents of having Internet.
ggplot(aes(x = benefit_internet_cat),
data = subset(sjdd_good_noint, benefit_internet_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Primary Benefit to Parents of having Internet") +
ylab("# of Respondents") +
ggtitle("Primary Benefit to Parents of having Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Top Barrier to get Internet.
ggplot(aes(x = internet_bar_top_cat),
data = subset(sjdd_good_noint, internet_bar_top_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Barrier to get Internet") +
ylab("# of Respondents") +
ggtitle("Top Barrier to get Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 20,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for 2nd Top Barrier to get Internet.
ggplot(aes(x = internet_bar_2nd_top_cat),
data = subset(sjdd_good_noint, internet_bar_2nd_top_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Top Barrier to get Internet") +
ylab("# of Respondents") +
ggtitle("2nd Top Barrier to get Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 20,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Top Service used by Parents to interact with friends.
ggplot(aes(x = nhi_pars_inter_ppl_cat),
data = subset(sjdd_good_noint, nhi_pars_inter_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Service used by Parents to interact with friends") +
ylab("# of Respondents") +
ggtitle("Top Service used by Parents to interact with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Assign appropriate names to random entries.
sjdd_good_noint$nhi_pars_inter_ppl_other_txt <- recode(sjdd_good_noint$nhi_pars_inter_ppl_other_txt,
"c('Ig', 'IG')='Instagram'")
# Subset dataframe and group by nhi_pars_inter_ppl_other_txt
Other_topPar_df <- subset(sjdd_good_noint, !is.na(sjdd_good_noint$nhi_pars_inter_ppl_other_txt)) %>%
group_by(nhi_pars_inter_ppl_other_txt) %>%
summarise(n = n())
# Create pie chart for other Top Service for Children interacting with Friends.
slices <- Other_topPar_df$n
lbls <- Other_topPar_df$nhi_pars_inter_ppl_other_txt
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = "")
pie(slices, labels = lbls, col = heat.colors(length(lbls)),
main = "Top other Services for Children Interacting with Friends", col.main = "#F7931E")
# Create barchart for 2nd Top Service used by Parents to interact with friends.
ggplot(aes(x = nhi_pars_2nd_inter_ppl_cat),
data = subset(sjdd_good_noint, nhi_pars_2nd_inter_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Top Service used by Parents to interact with friends") +
ylab("# of Respondents") +
ggtitle("2nd Top Service used by Parents to interact with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Assign appropriate names to random entries.
sjdd_good_noint$nhi_pars_2nd_inter_ppl_other_txt <- recode(sjdd_good_noint$nhi_pars_2nd_inter_ppl_other_txt,
"c('Ig', 'IG','Instant gram')='Instagram';
c('If')= NA;
c('Snap')='Snapchat'")
# Subset dataframe and group by nhi_pars_2nd__inter_ppl_other_txt
Other_2ndtopPar_df <- subset(sjdd_good_noint, !is.na(sjdd_good_noint$nhi_pars_2nd_inter_ppl_other_txt)) %>%
group_by(nhi_pars_2nd_inter_ppl_other_txt) %>%
summarise(n = n())
# Create pie chart for other 2nd Top Service for Children interacting with Friends.
slices <- Other_2ndtopPar_df$n
lbls <- Other_2ndtopPar_df$nhi_pars_2nd_inter_ppl_other_txt
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = "")
pie(slices, labels = lbls, col = heat.colors(length(lbls)),
main = "Other 2nd Top Services for Children Interacting with Friends", col.main = "#F7931E")
# Create barchart for Top Place for Parents to access Internet away from home.
ggplot(aes(x = internet_away_home_cat),
data = subset(sjdd_good_noint, internet_away_home_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Place for Parents to access Internet away from home") +
ylab("# of Respondents") +
ggtitle("Top Place for Parents to access Internet away from home") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Top Service used by Children to interact with friends.
ggplot(aes(x = nhi_child_comm_ppl_cat),
data = subset(sjdd_good_noint, nhi_child_comm_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Service used by Children to interact with friends") +
ylab("# of Respondents") +
ggtitle("Top Service used by Children to interact with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Assign appropriate names to random entries.
sjdd_good_noint$nhi_child_comm_ppl_other_txt <- recode(sjdd_good_noint$nhi_child_comm_ppl_other_txt,
"c('Ig', 'IG', 'Instate gram')='Instagram';
c('B','C','Face book','No answer','None','Other social media','Worrk', 'NA')= NA")
# Subset dataframe and group by nhi_child_comm_ppl_other_txt
Other_topPar_df <- subset(sjdd_good_noint, !is.na(sjdd_good_noint$nhi_child_comm_ppl_other_txt)) %>%
group_by(nhi_child_comm_ppl_other_txt) %>%
summarise(n = n())
# Create pie chart for other Top Service for Children interacting with Friends.
slices <- Other_topPar_df$n
lbls <- Other_topPar_df$nhi_child_comm_ppl_other_txt
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct)
lbls <- paste(lbls, "%", sep = "")
pie(slices, labels = lbls, col = heat.colors(length(lbls)),
main = "Top other Services for Children Interacting with Friends", col.main = "#F7931E")
# Create barchart for 2nd Top Service used by Children to interact with friends.
ggplot(aes(x = nhi_child_2nd_comm_ppl_cat),
data = subset(sjdd_good_noint, nhi_child_2nd_comm_ppl_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Top Service used by Children to interact with friends") +
ylab("# of Respondents") +
ggtitle("2nd Top Service used by Children to interact with friends") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Top Place for Children to access Internet away from home for homework.
ggplot(aes(x = child_where_access_cat),
data = subset(sjdd_good_noint, child_where_access_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Top Place for Children to access Internet \naway from home for homework") +
ylab("# of Respondents") +
ggtitle("Top Place for Children to access Internet \naway from home for homework") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
sjdd_good_noint$nhi_con_big_child_cat[sjdd_good_noint$nhi_con_big_child_cat == "Other concern"]<-NA
# Create barchart for Biggest Concern about Children's Internet use.
ggplot(aes(x = nhi_con_big_child_cat),
data = subset(sjdd_good_noint, nhi_con_big_child_cat != "")) +
theme_bw() +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
xlab("Biggest Concern about Children's Internet use") +
ylab("# of Respondents") +
ggtitle("Biggest Concern about Children's Internet use") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Create barchart for 2nd Biggest Concern about Children's Internet use.
ggplot(aes(x = nhi_con_2nd_big_child_cat),
data = subset(sjdd_good_noint, nhi_con_2nd_big_child_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Biggest Concern about Children's Internet use") +
ylab("# of Respondents") +
ggtitle("2nd Biggest Concern about Children's Internet use") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Create barchart for Most Trusted way to get help with signing up for home internet .
ggplot(aes(x = trust_signup_cat),
data = subset(sjdd_good_noint, trust_signup_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Most Trusted way to get help with \nsigning up for home internet") +
ylab("# of Respondents") +
ggtitle("Most Trusted way to get help with \nsigning up for home internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for 2nd Most Trusted way to get help with signing up for home internet .
ggplot(aes(x = trust_signup_2nd_cat),
data = subset(sjdd_good_noint, trust_signup_2nd_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("2nd Most Trusted way to get help with \nsigning up for home internet") +
ylab("# of Respondents") +
ggtitle("2nd Most Trusted way to get help with \nsigning up for home internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Amount Respondent can afford for Home Internet per month.
ggplot(aes(x = most_afford_internet_cat),
data = subset(sjdd_good_noint, most_afford_internet_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Amount Respondent can afford for \nHome Internet per month") +
ylab("# of Respondents") +
ggtitle("Amount Respondent can afford for \nHome Internet per month") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Create barchart for Biggest Barrier for Respondent to sign up Internet.
ggplot(aes(x = bar_signup_top_cat),
data = subset(sjdd_good_noint, bar_signup_top_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Biggest Barrier for Respondent to sign up Internet") +
ylab("# of Respondents") +
ggtitle("Biggest Barrier for Respondent to sign up Internet") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 18,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# What is your five-digit home zip code?
sjdd_good_noint$nhi_zipcode_txt <- as.character(sjdd_good_noint$nhi_zipcode_txt)
respondZip_no_Df <- subset(sjdd_good_noint, !is.na(sjdd_good_noint$nhi_zipcode_txt))
respondZip_no <- respondZip_no_Df %>%
group_by(nhi_zipcode_txt) %>%
summarise(value = n())
names(respondZip_no)[names(respondZip_no) == "nhi_zipcode_txt"] <- "region"
zip_choropleth(respondZip_no[respondZip_no$value>1,],
num_colors = 1,
zip_zoom = respondZip_no$region[respondZip_no$value>1],
legend = "# Response") +
scale_fill_gradient(high = "#11A7A5", low = "white",
guide = guide_colourbar(title = "# Respondents"))
# Create barchart for Total Combined Household Annual Income.
ggplot(aes(x = nhi_income_cat),
data = subset(sjdd_good_noint, nhi_income_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Total Combined Household Annual Income") +
ylab("# of Respondents") +
ggtitle("Total Combined Household Annual Income") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Create barchart for Housing Type.
ggplot(aes(x = nhi_affordable_housing_cat),
data = subset(sjdd_good_noint, nhi_affordable_housing_cat != "")) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Housing Type") +
ylab("# of Respondents") +
ggtitle("Housing Type of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Assign appropriate names to random entries.
sjdd_good_noint$nhi_other_housing_txt <- recode(sjdd_good_noint$nhi_other_housing_txt,
"c('A','additional to home','B','None','Other housing') = NA;
c('Apartments','Apt')='Apartment';
c('Rent','Rent a room','Renta','Renting')='Rental House';
c('Casa','Hose','House','House 2 bed')='Own a house';
c('Low income')='Low income housing';
c('Room mate','Room share')='Roommate'")
# Subset dataframe and group by nhi_other_housing_txt
Other_housing_df <- subset(sjdd_good_noint, !is.na(sjdd_good_noint$nhi_other_housing_txt)) %>%
group_by(nhi_other_housing_txt) %>%
summarise(n = n())
# Create bar chart for Other Housing type.
ggplot(data = Other_housing_df, aes(x = reorder(nhi_other_housing_txt, n), y = n)) +
geom_col(show.legend = FALSE,color = I('black'), fill = I('#11A7A5')) +
ggtitle(paste("Other Housing Type of Respondents")) +
theme_bw() +
xlab("Housing Type of Respondents") +
ylab("Number of Respondents") +
coord_flip() +
geom_label(aes(label = paste0(sprintf("%1.1f",
Other_housing_df$n/sum(Other_housing_df$n)*100), "%",
sep ="\n", n),
y = -1, fill = nhi_other_housing_txt),
show.legend = FALSE,
size = 3, label.padding = unit(0.1, "lines")) +
expand_limits(y = -1) +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5))
# Remove non-integer values.
sjdd_good_noint <- sjdd_good_noint[!is.na(as.numeric(
as.character(sjdd_good_noint$nhi_ppl_house_txt))),]
# Transform the variable nhi_ppl_house_txt to numeric
sjdd_good_noint$nhi_ppl_house_txt <- as.numeric(
as.character(sjdd_good_noint$nhi_ppl_house_txt))
# Create barchart for Number of People living the house.
ggplot(aes(x = nhi_ppl_house_txt), data = sjdd_good_noint) +
geom_histogram(binwidth = 1, color = I('black'), fill = I('#11A7A5')) +
scale_x_continuous(limits = c(0, 13), breaks = seq(0, 13, by = 1)) +
theme_bw() +
xlab("Number of People living the house") +
ylab("# of Respondents") +
ggtitle("Number of People living the house") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12))
# Create barchart for Gender of Respondents.
ggplot(aes(x = nhi_gender_cat), data = sjdd_good_noint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Gender") +
ylab("# of Respondents") +
ggtitle('Gender of Respondents') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))
# Create barchart for Ethnicity of Respondents.
ggplot(aes(x = nhi_race_cat), data = sjdd_good_noint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Race") +
ylab("# of Respondents") +
ggtitle("Race of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 22,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Transform the variable nhi_birth_year_txt to numeric.
sjdd_good_noint$nhi_birth_year_txt <- as.numeric(
as.character(sjdd_good_noint$nhi_birth_year_txt))
# Categorize nhi_birth_year_txt.
sjdd_good_noint$nhi_birth_year_txt.group <- cut(sjdd_good_noint$nhi_birth_year_txt,
c(1950, 1960, 1970,
1980, 1990, 2000),
labels = c( "1951-1960","1961-1970",
"1971-1980","1981-1990",
"1991-2000"),
right = TRUE)
# Create barchart for the year born of respondents.
ggplot(aes(x = nhi_birth_year_txt.group),
data = subset(sjdd_good_noint, !is.na(nhi_birth_year_txt.group))) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Year born of Respondents") +
ylab("# of Respondents") +
ggtitle("Year born of Respondents") +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 16,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 12)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
sjdd_good_noint$nhi_future_survey_cat[is.na(sjdd_good_noint$nhi_future_survey_cat)] <- "No"
# Create barchart for Willingness to participate in Future Survey.
ggplot(aes(x = nhi_future_survey_cat), data = sjdd_good_noint) +
geom_bar(color = I('black'), fill = I('#11A7A5')) +
theme_bw() +
xlab("Willingness to participate in Future Survey") +
ylab("# of Respondents") +
ggtitle('Willingness to participate in Future Survey') +
theme(plot.title = element_text(family = "Trebuchet MS",
color = "#F7931E",
face = "bold",
size = 20,
hjust = 0.5)) +
theme(axis.title = element_text(family = "Trebuchet MS", size = 14))