I tried to set color of points in ggplot and something not works.
Here is a simplified version of code.
library(tidyverse) get_point_color <- function(x) { if(x <= 10) s <- "red" if((x > 10) & (x <= 20)) s <- "orange" if((x > 20) & (x <= 50)) s <- "blue" s } mtcars %>% ggplot(aes(mpg, disp)) + geom_point(colour = get_point_color(mpg)) + geom_smooth() + theme_bw() Any help is appreciated!
