library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.1.3
## Warning in register(): Can't find generic `scale_type` in package ggplot2 to
## register S3 method.
library(ggrepel)
## Warning: package 'ggrepel' was built under R version 4.1.3
## Loading required package: ggplot2
library(RColorBrewer)
library(highcharter)
## Warning: package 'highcharter' was built under R version 4.1.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(ggplot2)
library(viridis)
## Warning: package 'viridis' was built under R version 4.1.3
## Loading required package: viridisLite
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.6 v dplyr 1.0.7
## v tidyr 1.1.4 v stringr 1.4.0
## v readr 2.1.1 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
data("mpg")
ggplot(data = mpg, aes(x = displ, y = hwy)) +
geom_point()
### Plot graph of MPG dataset
ggplot(mpg, aes(displ, hwy)) +
geom_point()
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
ggplot(mpg, aes(drv, hwy)) +
geom_boxplot()
ggplot(mpg, aes(drv, hwy, fill = drv)) +
geom_violin()
ggplot(mpg, aes(hwy, fill = "hwy")) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(mpg, aes(hwy, color = "red")) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(mpg, aes(manufacturer)) +
geom_bar()
ggplot(mpg) +
geom_bar(aes (fl), fill = "red")
ggplot(mpg)+
geom_bar(aes(fl, fill = class), position = "dodge")
ggplot(mpg) +
geom_bar(aes(fl, fill = class), position = "fill")
ggplot(mpg, aes(manufacturer)) +
geom_bar(fill = "dark green", color = "dark green")+
coord_flip()
ggplot(mpg, aes(drv, hwy)) +
geom_violin() +
geom_jitter()
ggplot(mpg) +
geom_point(aes(displ, hwy, color=drv)) +
facet_wrap(~ class, nrow = 2) +
theme_bw()
ggplot(mpg) +
geom_point(aes(displ, hwy)) +
facet_grid(drv ~ class)+
labs(x = "Displ", y = "Hwy", title = "Displacement on the Highway")