R - dot plot - colours of dots based on a range of values from a vector
<p>I have to simply dot plot in R, with V1 vs V2 in the data shown here. I want to set the color of dots based on a range of samples from the <code>individuals</code> column. For example, Here the dots should be of three colours: one color for the range from <code>HG097 - HG101</code>, second color for the range <code>HG1941 - HG1950</code>, and the third color for range <code>NA18542 - NA18547</code>. The data is:  </p>

<pre><code>individuals V1       V2
HG097      -0.0181  -0.0818
HG099      -0.0188  -0.0808
HG100      -0.021   -0.0753
HG101      -0.0196  -0.0804
HG1941     -0.0206   0.0174
HG1942     -0.031    0.0075
HG1944     -0.0291   0.0454
HG1945     -0.0245  -0.0128
HG1947     -0.0184  -0.0065
HG1950      0.006    0.0167
NA18542    -0.0296   0.0899
NA18543    -0.0318   0.1012
NA18544    -0.0305   0.096
NA18545    -0.0317   0.1068
NA18546    -0.0315   0.1016
NA18547    -0.0332   0.098  
</code></pre>

<p>Would the <code>split</code> function will work here along with the <code>plot</code>, as:  </p>

<pre><code>d &lt;- read.table("data_file", header =T)
split(d, c(HG097:HG101) &lt;- group1  
split(d, c(HG1941:HG1950) &lt;- group2
split(d, c(HG18542:HG18547) &lt;- group3
groups &lt;- c("group1", "group2", "group3")    
col &lt;- c("blue", "red", "green")
col.3 &lt;- rep(col, each=groups)
plot(d$V1, d$V2, pch=19, col=col.3)
</code></pre>

<p>Thanks for solution.</p>