R does not contain a function interp.surface!

This is from package 'fields', and according to the FAQ only the maintainer is allowed to send bug reports on a contributed package to R-bugs.

I am closing this report: please contact the maintainer (and do read the FAQ).

On Wed, 23 Mar 2005 [EMAIL PROTECTED] wrote:

On Wed, 23 Mar 2005 22:16:30 +0100 (CET), [EMAIL PROTECTED]
wrote :

R version: 2.001

(There is no such version of R.)

OS: Windows XP SP2

When I use the interp.surface() function, on occasion I have encountered
the following error message:

Error in interp.surface(a, loc) : subscript out of bounds

Since it is somewhat dependent on the data set, I cannot say exactly in
which cases these occur, but I believe I have found the problem and a
solution for it:

The scaling calculations in the code,
   lx <- ((nx - 1) * (loc[, 1] - xa))/xr + 1
   ly <- ((ny - 1) * (loc[, 2] - ya))/yr + 1
can lead to numerical error, so in the following lines
   lx1 <- ifelse(lx == nx, nx - 1, trunc(lx))
   ly1 <- ifelse(ly == ny, ny - 1, trunc(ly))
the equality statements which are the first arguments to the IF-ELSE
statements return false when they are supposed to be true. I believe the
remedy is to simply avoid absolute equalities, as in the following example
(which has worked for my problem):
   lx1 <- ifelse(abs(lx - nx) < 1e-10, nx - 1, trunc(lx))
   ly1 <- ifelse(abs(ly - ny) < 1e-10, ny - 1, trunc(ly))

I hope this is an appropriate posting for an error report. Thank you very
much for your hard work,

I think

ifelse(lx >= nx, nx - 1, trunc(lx))
ifelse(ly >= ny, ny - 1, trunc(ly))

would probably be a better fix, but I'd really like to see an example
of this in action.  Could you email me a dataset where you see it?

Duncan Murdoch

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



-- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to