Re: [R] uniform and clumped point plots

From: Ben Bolker <bolker_at_ufl.edu>
Date: Thu 18 May 2006 - 23:42:21 EST

Beutel, Terry S <Terry.Beutel <at> dpi.qld.gov.au> writes:

>
> I am trying to generate two dimensional random coordinates.
>
> For randomly distributed data I have simply used
>
> >xy<-cbind(runif(100),runif(100))
>
> However I also want to generate coordinates that are more uniformly
> distributed, and coordinates that are more contagiously distributed than
> the above.
>
>

here are some pictures I made for a talk recently, using the Poisson cluster process function from "splancs" and the Strauss process from "spatial" (I think)

library(splancs)
library(spatial)
set.seed(1001)
sq <- as.matrix(data.frame(x=c(0,1,1,0,0),y=c(0,0,1,1,0))) p.cl <- pcp.sim(rho=10,m=10,s2=0.001,region.poly=sq) plot(p.cl)
n <- nrow(p.cl)
p.ran <- matrix(runif(2*n),nrow=n,dimnames=list(NULL,c("x","y"))) ppregion()
p.reg <- Strauss(n,c=0.1,r=0.1)
p.reg <- matrix(c(p.reg$x,p.reg$y),nrow=n,dimnames=list(NULL,c("x","y"))) all <- data.frame(rbind(p.cl,p.ran,p.reg),

                  tr=rep(c("clustered","random","regular"),each=n))
library(lattice)
lattice.options(default.theme = ltheme) ## set as default ltheme <- col.whitebg()
ltheme$xyplot.background$col <- "transparent" ## change strip bg

trellis.par.set(theme=col.whitebg())
print(xyplot(y~x|tr,data=all,layout=c(3,1),aspect="iso",scales=list(draw=FALSE),

             bg="transparent",pch=16))

  Ben Bolker



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu May 18 23:47:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 19 May 2006 - 02:10:10 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.