**20**wrote:

Hello all,

This could be a trivial query but I am very new to R. I have data in two columns (Col X and ColY). Column X has ONLY positive values while Column Y has both positive and negative values. I would like to plot X vs Y, but with certain given ranges of negative and positive values of Y, in different colors. For example my data is like:

X Y

5.89558 5.79116

4.83266 2.66533

5.21103 1.42206

3.83974 -7.67948

4.47855 -8.95710

4.66096 -3.32192

9.77715 -2.03952

8.17131 -5.11321

4.86396 -1.72792

I would like to plot value of negative subset of Y ranging from (< 0 to -4) in one color (say red) and the subset positive values of Y ranging between (>0 to 4) in green. And rest of the values in Grey.

I would really appreciate help in defining conditional subset in R and plotting them in different colors.

Thanks

Hello Anki!

We believe that this post does not fit the main topic of this site.

What andrew.j.skelton73 said. However, the general idea is

`col=ifelse(Y<0, "blue", "red")`

.For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

93k