In this project when I do steps 6 to 8 nothing happens.
Here is the code that I type in:
# filter to reasonable education levels
psid_clean <- psid_clean %>% filter(between(education_years, 5, 25))
# plot income
labor_boxplot <- psid_clean %>%
ggplot(aes(labor_income, labor_income)) +
What’s going on here? Am I doing something wrong or is there a bug?
Based on the code you provided, it seems that you are filtering the data to keep only the observations where education_years variable falls between 5 and 25, and then creating a boxplot of labor_income variable using ggplot2. Finally, you are printing a summary of labor_income variable.
It is possible that there is no output or plot generated by these commands if there are no observations in your dataset that meet the filter condition (i.e., have education_years between 5 and 25). In that case, psid_clean will be an empty data frame and there will be no data to plot.
You can check whether there are any observations left in psid_clean after the filtering step by typing:
This will tell you the number of rows in the dataset after the filter has been applied. If this number is 0, then there are no observations left in the dataset and you need to adjust your filtering criteria.
If there are still observations in psid_clean, but you’re not seeing the boxplot, it is possible that your plot window is not open or visible. You can try running the code in a fresh R session or opening a new plot window by typing:
depending on your operating system. This should open a new window where your plots will be displayed. Alternatively, you can save the plot to a file by adding a line like this to the end of your ggplot code:
This will save the plot to a file named “myplot.png” in your working directory.
I hope this helps! Let me know if you have any questions