Using Conditional Statements to Change the Color of Data Points

后端 未结 4 834
攒了一身酷
攒了一身酷 2021-01-13 08:39

I have a data set, which I have used to make a scatter plot and I would like to assign three different colors to the data points within three different regions, based on the

4条回答
  •  逝去的感伤
    2021-01-13 09:27

    I like the cut approach:

    set.seed(1)
    x <- sample(1600)
    col <- c("red", "black", "purple")
    col <- col[cut(x, breaks=c(-Inf, 3, 1549, Inf))]
    

提交回复
热议问题