# install.packages("ggplot2")
# install.packages("ggExtra")
library(ggplot2)
library(ggExtra)
dat<- read.csv(file.choose())
colnames(dat)
# Save the scatter plot in a variable
p <- ggplot(dat, aes(x = Speed_2017_to_2019, y = Volume_2017_to_2019)) +
geom_point(shape=5, color="gray")+
ylim(0, 100)+
xlim(0, 100)+
geom_smooth(method=lm, color="darkred", fill="blue")+
theme_classic()
# Densigram
ggMarginal(p, type = "densigram",
xparams = list(fill = 4),
yparams = list(fill = 3))
# Save the scatter plot in a variable
p <- ggplot(dat, aes(x = Speed_2020, y = Volume_2020)) +
geom_point()+
ylim(0, 100)+
xlim(0, 100)+
geom_smooth(method=lm)+
theme_classic()
#scale_size_manual(values=c(2,3,4))
#p + scale_y_discrete(limits=c("0", "100", "200", "300", "400"))
#p + scale_x_discrete(limits=c("0", "30", "60", "90", "120"))
# Densigram
ggMarginal(p, type = "densigram",
xparams = list(fill = 4),
yparams = list(fill = 3))
# Save the scatter plot in a variable
p <- ggplot(dat, aes(x = Crash_2020, y = Speed_2020)) +
geom_point()+
geom_smooth(method=lm, color="darkred", fill="blue")
# Densigram
ggMarginal(p, type = "densigram",
xparams = list(fill = 4),
yparams = list(fill = 3))