setwd("C:/Users/subas/Syncplicity/MyProjects_IMP/MY_Papers_V2/TRB 2021/00 0a Uber_SeatBelt/data_code")
library(readxl)
library(SmartEDA)
library(data.table)
uu <- read_excel("Edu.xlsx", sheet="uu1_Edu")
uu1= subset(uu[,-c(9)], VARIABLE=="17a")
uuu= melt(setDT(uu1),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==17)
uu2= uu2[,-c(9)]
uuu2= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==18)
uu2= uu2[,-c(9)]
uuu3= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==28)
uu2= uu2[,-c(9)]
uuu4= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
library(ggplot2)
a1= ggplot(uuu,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=9))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=12))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1a= ggplot(uuu2,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Ride Share without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1b= ggplot(uuu3,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Used Taxi without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1c= ggplot(uuu4,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Important Factors for Ride Sharing")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
nu <- read_excel("Edu.xlsx", sheet="nn1_Edu")
nu1= subset(nu[,-c(9)], VARIABLE=="17a")
nuu= melt(setDT(nu1),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==17)
nu2= nu2[,-c(9)]
nuu2= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==18)
nu2= nu2[,-c(9)]
nuu3= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==28)
nu2= nu2[,-c(9)]
nuu4= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
a2= ggplot(nuu,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2a= ggplot(nuu2,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Ride Share without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2b= ggplot(nuu3,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Used Taxi without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2c= ggplot(nuu4,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Important Factors for Ride Sharing")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
library(gridExtra)
library(grid)
grid.arrange(a1, a2, ncol=1)
GEN
library(data.table)
uu <- read_excel("Edu.xlsx", sheet="uu1_Gen")
uu1= subset(uu[,-c(6)], VARIABLE=="17a")
uuu= melt(setDT(uu1),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==17)
uu2= uu2[,-c(6)]
uuu2= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==18)
uu2= uu2[,-c(6)]
uuu3= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
uu2= subset(uu, Ques==28)
uu2= uu2[,-c(6)]
uuu4= melt(setDT(uu2),id.vars = c("VARIABLE", "CATEGORY"))
library(ggplot2)
a1= ggplot(uuu,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=9))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=12))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1a= ggplot(uuu2,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Ride Share without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1b= ggplot(uuu3,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Used Taxi without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a1c= ggplot(uuu4,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - RideShared with Kids \n Important Factors for Ride Sharing")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
nu <- read_excel("Edu.xlsx", sheet="nn1_Gen")
nu1= subset(nu[,-c(6)], VARIABLE=="17a")
nuu= melt(setDT(nu1),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==17)
nu2= nu2[,-c(6)]
nuu2= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==18)
nu2= nu2[,-c(6)]
nuu3= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
nu2= subset(nu, Ques==28)
nu2= nu2[,-c(6)]
nuu4= melt(setDT(nu2),id.vars = c("VARIABLE", "CATEGORY"))
a2= ggplot(nuu,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2a= ggplot(nuu2,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Ride Share without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2b= ggplot(nuu3,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Used Taxi without Kids")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
a2c= ggplot(nuu4,aes(x = variable, y = value, fill = CATEGORY, label = value)) +
geom_bar(stat = "identity") +theme_bw()+ coord_flip()+
scale_fill_manual(values=c("#D8A499", "#81A88D", "#78B7C5","#C7B19C", "#CDC08C", "grey"))+
theme(text = element_text(size=12))+labs(y="Percentage", x="Q38, Q17 - Never RideShared with Kids \n Important Factors for Ride Sharing")+
geom_text(size =3,position = position_stack(vjust = 0.5))+
theme(legend.text=element_text(size=9))+ facet_grid(VARIABLE ~ .)+
theme(axis.text.x = element_text(size=12), axis.text.y = element_text(size=12))+
theme(axis.title=element_text(size=12))+
theme(legend.position="bottom")
library(gridExtra)
library(grid)
grid.arrange(a1, a2, ncol=1)

grid.arrange(a1a, a2a, ncol=2)

grid.arrange(a1b, a2b, ncol=2)

grid.arrange(a1c, a2c, ncol=2)
