#Task 1
data <-mtcars
View(data)
table(data$mpg)
## 
## 10.4 13.3 14.3 14.7   15 15.2 15.5 15.8 16.4 17.3 17.8 18.1 18.7 19.2 19.7   21 
##    2    1    1    1    1    2    1    1    1    1    1    1    1    2    1    2 
## 21.4 21.5 22.8 24.4   26 27.3 30.4 32.4 33.9 
##    2    1    2    1    1    1    2    1    1
#Load ggplot2 and Data
library(ggplot2)
#Create Bar Chart using ggplot2
barplot(table(data$mpg), 
        xlab="mpg of cars", 
        ylab="Numbers", 
        main="Cars according to mpg", 
        col="green")

#Load ggplot2 and Data
library(ggplot2)
#Create Scatter Plot using ggplot2
ggplot(data)+
  geom_point(mapping=aes(x=mpg,y=gear, alpha=mpg), col="red")

# Load ggplot2
library(ggplot2)
#Create Box Plot using ggplot2
ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl))) +
  geom_boxplot() +
  labs(
    title = "Fuel Efficiency by Cylinder Count",
    x = "Number of Cylinders",
    y = "Miles Per Gallon",
    fill = "Cylinders"
  ) +
  theme_minimal() +
  scale_fill_brewer(palette = "Blues") +
  stat_summary(fun = "mean", geom = "point", shape = 23, size = 3, fill = "black")

#Task2
ggplot(data, aes(x=wt, fill=factor(cyl))) + 
  geom_histogram(binwidth=.07, colour="Red", alpha=0.7) +
  geom_density(alpha=.3) +
  labs(
    title = "Histrogram for wt",
    subtitle = "Density by wt",
    caption = "Dataset: mtcars (R built-in)",
    fill = "Cylinders"
  )