Coloring the points by category in R
问题 I am creating a scatter plot in R using the following code: plot(df_prob1$x1, df_prob1$x2, pch = df_prob1$y) I get the following plot: As seen in the above plot there are two categories, one represented by a square and the other by circle. I want these two categories to have different colors as well. I did try using the following code: plot(df_prob1$x1, df_prob1$x2, pch = df_prob1$y, col = c("red", "blue")) And I get the following plot: However, it is randomly coloring points and not taking