library(ggplot2)
library(dplyr)
library(ISLR)
data("Credit")
data("Wage")
What is the overall distribution of credit scores in the dataset?
ggplot(Credit, aes(x = Rating)) +
geom_histogram(binwidth = 50, fill = "skyblue", color = "black") +
labs(x = "Credit Score", y = "Count", title = "Distribution of Credit Scores")
How do credit scores vary across different age groups within the dataset?
ggplot(Credit %>% group_by(Age) %>% summarize(mean_credit_score = mean(Rating, na.rm = TRUE)), aes(x = Age, y = mean_credit_score)) +
geom_line() +
labs(x = "Age", y = "Average Credit Score", title = "Average Credit Score by Age")
How does payment history affect the average credit score among individuals?
ggplot(Credit, aes(x = Married, y = Rating, fill = Married)) + geom_boxplot() + labs(x = "Marital Status", y = "Credit Score", title = "Impact of Marital Status on Credit Score")
What is the relationship between credit utilization ratios and credit scores in the dataset?
ggplot(Credit, aes(x = Balance / Limit, y = Rating)) + geom_point(alpha = 0.6) + labs(x = "Credit Utilization Ratio", y = "Credit Score", title = "Relationship Between Credit Utilization Ratio and Credit Score")
How have credit scores changed over the past few years? Are there noticeable trends?
ggplot(Credit, aes(x = Age, y = Rating)) + geom_point(alpha = 0.6) + geom_smooth(method = "loess", color = "blue") + labs(x = "Age", y = "Credit Score", title = "Credit Score Trends by Age")
What is the distribution of wages in the dataset, and how does it compare to national averages?
ggplot(Wage, aes(x = wage)) + geom_histogram(binwidth = 1000, fill = "skyblue", color = "black") + geom_vline(xintercept = 50000, linetype = "dashed", color = "red") + labs(x = "Wage", y = "Count", title = "Distribution of Wages with National Average")
What are the average wages across different industries represented in the dataset?
ggplot(Wage, aes(x = jobclass, y = wage)) + geom_boxplot(fill = "skyblue", color = "black") + labs(x = "Industry", y = "Wage", title = "Wage Distribution by Industry")
How have wages changed over time within the dataset? Are there specific periods of growth or decline?
ggplot(Wage, aes(x = year, y = wage)) + stat_summary(fun = "mean", geom = "line", color = "blue") + labs(x = "Year", y = "Average Wage", title = "Wage Growth Over Time")
How do wages differ by education level, and is there a significant correlation between education and wage?
ggplot(Wage, aes(x = education, y = wage)) + stat_summary(fun = "mean", geom = "bar", fill = "skyblue", color = "black") + labs(x = "Education Level", y = "Average Wage", title = "Average Wage by Education Level")
How do wages vary between full-time, part-time, and contract workers in the dataset?
ggplot(Wage, aes(x = jobclass, y = wage)) + geom_boxplot(fill = "skyblue", color = "black") + labs(x = "Employment Type", y = "Wage", title = "Wage Distribution by Employment Type")