[R] ordering points as vertex of a polygon
Luca Scrucca
luca at stat.unipg.it
Mon Jun 14 11:42:13 CEST 2004
Dear R-users,
Suppose I have the following x-y coordinates which give the boundaries of
a polygon:
> x <- c(5,4,5,9,6,6,4,7,10,7,10,4,10)
> y <- c(6,3,2,6,3,7,5,4,4,7, 5,4, 6)
I would like to plot the following graph:
> plot(x,y)
> ord <- c(7,12,2,3,5,8,9,11,13,4,10,6,1)
> polygon(x[ord],y[ord])
How I can obtain the above ordering (in the example an anti-clockwise
ordering) such that I can use polygon() to connect the points?
I searched previous messages but I did not find any relevant to this
problem.
Thanks,
Luca
+-----------------------------------------------------------------------+
| Dr. Luca Scrucca |
| Dipartimento di Scienze Statistiche tel. +39 - 075 - 5855278 |
| Università degli Studi di Perugia fax. +39 - 075 - 5855950 |
| Via Pascoli - C.P. 1315 Succ. 1 |
| 06100 PERUGIA (ITALY) |
| (o_ (o_ (o_ |
| E-mail: luca at stat.unipg.it //\ //\ //\ |
| Web page: http://www.stat.unipg.it/luca V_/_ V_/_ V_/_ |
+-----------------------------------------------------------------------+
More information about the R-help
mailing list