Load ggplot2 for visualization

library(ggplot2) library(scales)

Import the dataset

df <- read.csv(“C:/Users/LENOVO/Downloads/workshop 2.csv”)

column names

names(df)

A bar plot to show the relationship between education and loan status

ggplot(data = df, aes(x = education, fill = loan)) + geom_bar(position = “fill”) + # proportionate bar (100% stacked) scale_y_continuous(labels = percent_format()) + scale_fill_manual(values = c(“#FF9999”, “#3399FF”)) +
labs( title = “Loan Status by Education Level”, subtitle = “Proportion of people with and without loans across education levels”, x = “Education Level”, y = “Proportion of Respondents”, fill = “Has Loan?”, caption = “Source: Workshop 2 Dataset” ) + theme_minimal() + theme( plot.title = element_text(size = 16, face = “bold”), plot.subtitle = element_text(size = 12), axis.title = element_text(size = 12), legend.title = element_text(size = 12) ) + coord_cartesian(ylim = c(0, 1))