I have the data frame df, structured like this:
age salary graduate
19 22000 "no"
25 24000 "yes"
23 26000 "yes"
30 30000 "no"
I made the plot of the salary as a function of age, changing the color of the dot whether the person is a graduate or not in this way:
plot(df$age, df$salary, col=ifelse(df$graduate=="yes", "blue", "red"), pch=16, xlab="age", ylab="salary")
How can I add a legend titled "Graduate" with an explanation of the color of the dots (i.e. blue dot = graduate, red dot = not graduate)?
