head(mpg)
## # A tibble: 6 x 11
## manufacturer model displ year cyl trans drv cty hwy fl class
## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
## 1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compa~
## 2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compa~
## 3 audi a4 2 2008 4 manual(m6) f 20 31 p compa~
## 4 audi a4 2 2008 4 auto(av) f 21 30 p compa~
## 5 audi a4 2.8 1999 6 auto(l5) f 16 26 p compa~
## 6 audi a4 2.8 1999 6 manual(m5) f 18 26 p compa~
names(mpg)
## [1] "manufacturer" "model" "displ" "year" "cyl"
## [6] "trans" "drv" "cty" "hwy" "fl"
## [11] "class"
plot1<-mpg %>%
ggplot(aes(displ,hwy))+geom_point(aes(col=class))+geom_smooth(se=F)+labs(title = "Fuel efficiency generally decreases with engine size",subtitle = "Created by Md Sojbul Islam",caption = "Scatterplot")+theme(plot.title = element_text(hjust = 0.5))+theme_classic()
ggplotly(plot1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
plot1<-mpg %>%
ggplot(aes(displ,hwy))+geom_point(aes(col=class))+geom_smooth(se=F)+labs(title = "Fuel efficiency generally decreases with engine size",subtitle = "Created by Md Sojbul Islam",x="Engine displamnet",y="Highway fuel economey", col="car type",caption = "Scatterplot")+theme(plot.title = element_text(hjust = 0.5))+theme_classic()
plot1
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
df <- tibble(
x = runif(10),
y = runif(10)
)
mt<-ggplot(df, aes(x, y)) +
geom_point(size=2) +
labs(
x = quote(sum(x[i] ^ 2, i == 1, n)),
y = quote(alpha + beta + frac(delta, theta))
)+geom_line(col="blue")
mt
best_in_class <- mpg %>%
group_by(class) %>%
filter(row_number(desc(hwy)) == 1)
la<-ggplot(mpg, aes(displ, hwy)) +
geom_point(aes(colour = class)) +
geom_text(aes(label = model), data = best_in_class)
ggplotly(la)