[R] reason for error in small function?

Dale Steele dale.w.steele at gmail.com
Thu Oct 11 20:17:14 CEST 2007


Running the function below, tested using the cardiff dataset from
splancs generates the following error.   What changes do I need to
make to get the function to work?  Thanks.  --Dale

> gen.rpoints(events, poly, 99)
> rpoints
Error: object "rpoints" not found

# test spatial data
library(splancs)
data(cardiff)
attach(cardiff)
str(cardiff)
events <- as.points(x,y)

### non-working function ####

gen.rpoints <- function(events, poly, nsim){
rpoints <- array(0, dim=c(nrow(events),2,nsim))
  for (i in 1:nsim) {
    rpoints[, ,i] <- csr(poly, nrow(events))
  }
}



More information about the R-help mailing list