A) The visual created for this analysis is a scatter plot with a regression line, which shows the relationship between total income (clt_inc) and age (clt_ind_age) for the three specified education levels (clt_education): high school, university undergraduate program, and university PhD program. The plot is created using the ggplot2 package in R, which allows for easy customization of plot elements to improve readability and avoid overplotting.
Methodology:
Load the Clean_Q2.csv dataset into R using the read.csv() function.
Filter the dataset to include only the three specified education levels using the filter() function from the dplyr package.
Create a new variable called "group" to identify the different education levels using the mutate() function from the dplyr package.
Plot the total income (clt_inc) against age (clt_ind_age) for each education level using the ggplot() function from the ggplot2 package.
Add a regression line for each education level using the geom_smooth() function from the ggplot2 package with the method set to "lm".
Customize the plot elements to improve readability and avoid overplotting, including:
Setting the plot title using the labs() function from the ggplot2 package.
Setting the x-axis and y-axis labels using the scale_x_continuous() and scale_y_continuous() functions from the ggplot2 package.
Adding a legend to identify the different education levels using the guide_legend() function from the ggpubr package.
Saving the plot as a png file using the ggsave() function from the ggplot2 package.
B) The methodology used to create the visual was to use the ggplot2 package in R to create a scatter plot with a regression line. This approach was chosen because it allows for easy customization of plot elements to improve readability and avoid overplotting. By adding a regression line for each education level, we can see the overall trend in total income by age for each group. To improve readability, we set appropriate axis labels, added a plot title, and added a legend to identify the different education levels. We also saved the plot as a png file to ensure that it can be easily viewed and shared.
C) Based on the visual created, we can see that there is a positive relationship between total income (clt_inc) and age (clt_ind_age) for all three education levels. However, the strength of this relationship varies between the different education levels. The university PhD program group has the strongest relationship, with a steeper regression line, while the high school group has the weakest relationship, with a flatter regression line.
These results are generally in line with our expectations, as higher levels of education are often associated with higher incomes. However, there are some interesting differences between the groups. For example, the university undergraduate program group has a slightly weaker relationship between total income and age compared to the university PhD program group. This could be due to differences in the types of jobs and career paths pursued by individuals with different levels of education.