library(ggplot2)
library(dplyr)
library(ISLR)
data("Credit")
data("Wage")

Credit Data Questions:

1)Credit Score Distribution:

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")

2)Credit Score by Age Group:

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")

3)Impact of Payment History:

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")

4)Credit Utilization Ratio:

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")

Wage Data Questions:

1)Wage Distribution:

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")

2)Average Wage by Industry:

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")

3)Wage Growth Over Time:

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")

4)Wage vs. Education Level:

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")

5)Impact of Employment Type:

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")