Let us first call the library ggplot2 as follows,
library(ggplot2)
data1 = read.csv("C:/Users/Lenovo/OneDrive/Desktop/instadata/Nawapet A&V Week 5 Advanced Graphs in RStudio/dataset_student_survey_data(2).csv", header = TRUE)
data1_new = subset(data1, Sex != "NA")
ggplot(data1_new, aes(Smoke))+geom_bar(aes(fill = Exer), position = "dodge")+facet_grid(Sex~.)+ggtitle("The Exercise habits of Male and Female students that smoke")+xlab("Smoker")+ylab("Counts")
data2 = read.csv("C:/Users/Lenovo/OneDrive/Desktop/instadata/Nawapet A&V Week 5 Advanced Graphs in RStudio/dataset_us_car_price_data(1).csv", header = TRUE)
ggplot(data2, aes(Price))+geom_histogram(aes(fill = Type))+facet_grid(Type~.)+ggtitle("Car Price Distribution based on Car Type")+xlab("Price")+ylab("Freq")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
data3 = read.csv("C:/Users/Lenovo/OneDrive/Desktop/instadata/Nawapet A&V Week 5 Advanced Graphs in RStudio/dataset_production_of_rice_in_india.csv", header = TRUE)
ggplot(data3, aes(x=varieties, y=price))+geom_boxplot(aes(fill = bimas))+facet_grid(status~.)+ggtitle("India Rice Prices based on Varieties, Land Status, and Bimas Program")+xlab("Rice Varieties")+ylab("Price")
ggplot(data3, aes(x=price, y=wage))+geom_point(aes(shape = bimas, col = bimas))+geom_smooth(method = lm, se = FALSE)+facet_grid(status~.)+ggtitle("India Rice Prices vs Wage broken down by Land Status and Bimas Program")+xlab("Rice Price")+ylab("Wage")
## `geom_smooth()` using formula 'y ~ x'