[R] interp() function output not continue

Dieter Vanderelst dieter_vanderelst at emailengine.org
Tue Jun 17 15:52:55 CEST 2008


Dear List,

I'm using interp() to prepare 3d data for plotting with the contour() function.

If have x,y and z data. All are arrays. X and Y are sampled in an orderly fashion on a grid (a circular sub-area of a grid - see plot). I'm trying to use interp() to get x and y arrays and a z matrix that can be fed to contour().

This is the command: interp(x,y,z,extrap=F,linear=FALSE,duplicate='mean')

In the result there are, consistently, some discontinuities. This happens always in the 'middle' of the data.

I've uploaded a plot that might clarify the problem: http://examples.attic.sent.com/example.png

As you can see the middle of the plot is discontinue. When I look at the data, there is no particular reason why this should happen. 

The problem seems to be a single row in the z matrix returned by interp() right in the middle of the matrix (line 30 of 60). Replacing this line with the mean of row 29 and 31 seems to solve the problem. This results in this plot: http://examples.attic.sent.com/example_fix.png. This works, but it is not nice of course.

Is this something that looks familiar to someone? Can I replace the interp() function with something else? Could this be due to the particular way my data is sampled?

Regards,
Dieter



More information about the R-help mailing list