[R] Random Cluster Generation Question

Jason L. Simms jlsimms at gmail.com
Thu Apr 9 23:01:26 CEST 2009


Hello,

I am fairly new to R, but I am not new to programming at all.  I want
to generate random clusters in a 1,000x1,000 box such that I end up
with a total of about 2,000 points.  Once done, I need to export the
X,Y coordinates of the points.

I have looked around, and it seems that the spatstat package has what
I need.  The rMatClust() function can generate random clusters, but I
have run into some problems.

First, I can't seem to specify that I want x number of points.  So,
right now it appears that if I want around 2,000 total points that I
must play around with the parameters of the function (e.g., mean
number of points per cluster, cluster radius, etc.) until I end up
with roughly 2,000 points.

More problematic, however, is that specifying a 1,000x1,000 box is too
much to handle.  I have been running the following function for over
24 hours straight on a decent computer and it has not stopped yet:

clust <- rMatClust(1, 50, 5, win=owin(c(0,1000),c(0,1000)))

Clearly, I need to rethink my strategy.  Could I generate the points
in a 10x10 box with a radius of .5 and then multiply out the resulting
point coordinates by 100?  Is there another package that might meet my
needs better than spatstat for easy cluster generation?

Any suggestions are appreciated.

All the best,
Jason Simms

-- 
Jason L. Simms, M.A.
USF Graduate Multidisciplinary Scholar
Co-President, Graduate Assistants United
Ph.D. / M.P.H. Student
Departments of Anthropology and Environmental and Occupational Health
University of South Florida




More information about the R-help mailing list