how can i loop string variables and display all the outer point for each type
<p>Raw data</p>

<pre><code>rawdata &lt;- read.table(text = "segment type    x   y
                  kl  a   1   3
                  kl  a   2   1
                  kl  a   3   10
                  kl  a   6   3
                  kl  a   8   2
                  kl  a   4   6
                  kl  a   3   5
                  kl  a   2   4
                  kl  a   7   10
                  mk  d   1   3
                  mk  d   2   1
                  mk  d   3   9
                  mk  d   6   3
                  mk  d   8   2
                  mk  d   4   6
                  mk  d   3   5
                  mk  d   2   4
                  mk  d   7   6
                  mk  d   9   1
                  mk  d   10  10", header = T)
</code></pre>

<p>I want to looping rawdata$type and it will bind all the outer point for a and d.</p>

<p>the outer point formula:</p>

<pre><code>x &lt;- data.frame(rawdata$x,rawdata$y)
plot(x)
chx &lt;- chull(x)
chx &lt;- data.frame(rbind(x = x[chx, ], x[chx[1], ]))
lines(chx)
chx
</code></pre>