[R] spatstat sub-selection

Joris Meys jorismeys at gmail.com
Sun Jun 6 12:59:25 CEST 2010


You can't specify it in rthin, which I can understand for the simple
reason that this violates the independence of the sampling. If you put
a fixed limit on your resampling, the chance of being selected depends
on when some point is selected.

You could do it by hacking the object :

rthin.exact <- function(x,n){
    l <- x$n
    i <- sample(1:l,n,replace=F)
    x$n <- n
    x$x <- x$x[i]
    x$y <- x$y[i]
    return(x)
}

data(redwood)
plot(redwood, main="thinning")

  # keep 30 points
  Y <- rthin.exact(redwood, 30)
  points(Y, col="green", cex=1.4)

Cheers
Joris

On Sun, Jun 6, 2010 at 12:26 AM, Tom_R <tom.richardson at bristol.ac.uk> wrote:
>
> Fellow Users,
>
> In Spatstat, if you have a ppp object with, say 100 points, how do you
> create another ppp containing a random selection, N, of the original?
>
> You can tell the function 'rthin' to make a sub-selection of points, i.e.
> "every point is removed with probability 0.5" but you CAN'T set N exactly...
>
> I'm sure this should be easy...
>
> Ta!
>
> Tom
> --
> View this message in context: http://r.789695.n4.nabble.com/spatstat-sub-selection-tp2244619p2244619.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list