Shahadat
Shahadat
library(ggplot2)
# Line plot without confidence intervals
ggplot(mpg, aes(x=displ, y=hwy, color=drv)) +
geom_smooth(method="lm", se=FALSE) +
labs(title="Engine Displacement vs Highway Mileage",
x="Engine Displacement (L)", y="Highway Mileage (mpg)")
# Answer 6:
ggplot(mpg, aes(x = class, y = hwy)) +
geom_boxplot() +
labs(title = "Highway Mileage by Vehicle Class",
x = "Vehicle Class",
y = "Highway Mileage (mpg)") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Answer 7:
ggplot(mpg, aes(x = class)) +
geom_bar() +
labs(title = "Distribution of Vehicle Classes",
x = "Vehicle Class",
y = "Count")
# Answer 8:
# Answer 9:
# Answer:10
library(dplyr)
# 10.1 Create a new column for total fuel consumption
mpg_clean <- mpg_clean %>%
mutate(total_fuel_consumption = cty + hwy)
# 10.3 Filter for vehicle classes with avg engine size > 3.0L
large_engine_classes <- avg_data %>%
filter(avg_engine_size > 3.0)