Entering edit mode
9.2 years ago
Anushka
▴
20
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