A couple of my functions that were working last week seem to have been changed over the weekend and no longer work, but I can't understand why not: it seems that objects defined at the start of the function are not located further on in the function, when this worked fine before. An example follows at the end, using the package spatstat, though the problem seems more general. My only guess is that I've accidentally changed something to do with the environment that functions are searching in to exclude themselves, but if so I've no idea how I did or how I can cancel it!
Thanks in advance, Colin library (spatstat) kernelEst <- function (data, max.r = 10, edge = TRUE) { if (!is.ppp (data)) stop ("data must be a point process object") i <- 0.1 diff <- 1 smo <- 1 while (diff > 0) { olddiff <- diff oldsmo <- smo smo <- density.ppp (data, sigma = 2 * i, edge = edge) lambda <- smo[data] Ki <- Kinhom (data[,data$window], lambda = lambda, r = seq (0, max.r, length = 100), correction = "trans") diff <- sum (Ki$theo - Ki$trans) i <- i + 0.1 if (i > max.r) stop ("no suitable kernel found within 0.2 to max.r") } if (abs (olddiff) > abs (diff)) return (smo) else return (oldsmo) } data (simdat) test <- kernelEst (simdat) Error in while (diff > 0) { : missing value where TRUE/FALSE needed > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 2.1 year 2005 month 12 day 20 svn rev 36812 language R ______________________________________________ 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