[R] selecting clusters of points
Roger Bivand
Roger.Bivand at nhh.no
Fri Jan 25 22:43:00 CET 2002
On Fri, 25 Jan 2002, Tony Long wrote:
> Are there any functions out there for selecting all the
> points in a region of a plot. I envision something like the
> identify() function except one could circle a cloud of points (and
> perhaps a vector would be returned of the same length as the points
> plotted indicating logical membership in the circled cloud). Perhaps
> someone has done something with the locator() function that would
> allow this (or can suggest a way I could do this). Thanks. Tony
>
At least one possibility is:
> library(splancs)
> poly <- cbind(x=c(0,0,1,1), y=c(0,1,1,0))
> data <- csr(poly, 50)
> plot(data)
> subset <- getpoly()
-- here interactively choose your polygon --
> inout(data, subset)
-- outputs logical vector for points within subset polygon --
If you need to resolve for points precisely on the polygon boundaries,
pip() may be more help. The subset polygon could be constructed
non-interactively too, but needs to be a polygon.
Roger
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list