[R] persp fail with non-equidistant dates

Duncan Murdoch murdoch.duncan at gmail.com
Mon Aug 22 20:57:40 CEST 2016


Please keep discussion on the mailing list.

On 22/08/2016 12:08 PM, Tomas Bayer wrote:
> Hello,
> we have tried the pre-processing till now but also with this error message:
>
> akima.li <- interp(x, y, F, xo=seq(min(x), max(x), length = 100),
> yo=seq(min(y), max(y), length = 100))
> Error: could not find function "interp"
>
> We have tried the same with interp.old and interp.new.
> We also got the same error message by packages akima and rgl although they
> are installed (confirmed by apt and synaptic, too).
> Till now, all interpolation routines have failed.
> What would we use as the ideal preparation to persp and contour?

If you are using the interp() function from the akima package,  it 
appears you didn't attach it.  Use

library( pkg )

to attach a package named "pkg".  You may need to install the package 
first; use

install.packages("akima")

if so.

The variable name F may cause you problems: many people use F as an 
abbreviation for FALSE; it's a standard variable defined in the base 
package.  It's a good idea to avoid masking that and causing yourself 
confusion later.

If this advice doesn't fix your problem, then please post a reproducible 
example for others to try.  You might want to select a subset of your 
data if it's too big or too private to post here.

Duncan Murdoch


> Thanks,
>
> Tomas Bayer
>
>> On 22/08/2016 11:17 AM, Tomas Bayer wrote:
>>> Hello,
>>> when I plotted non-equidistant data in 3D (using persp and contour), it
>>> was ended with the same error message:
>>>
>>>> persp(y, x, z, xlab="latitude", ylab="longitude", zlab="altiude",
>>> main="Altitude")
>>> Error in persp.default(y, x, z, xlab = "latitude", ylab = "longitude",
>>> :
>>>   increasing 'x' and 'y' values expected
>>>
>>> How to fix it? The original data are in columns
>>>
>>>  50.84925    14.65715 614.0  48909.14   -62.49  99  48929  5  122306
>>>  50.84919    14.65702 617.0  48816.32  -145.82  69  48836  6  122331
>>>  50.84908    14.65681 622.0  49113.40     6.64  99  49133  4  122442
>>
>> You haven't shown us what is in y, x and z, but it looks as though you
>> haven't got data in the form required by persp, i.e. a vector of
>> increasing values in each of the first two arguments, and a matrix of
>> values in the third.  Using your variable names, you'd want z[i,j] to
>> correspond to y[i] and x[j].
>>
>> If you just have a collection of (y, x, z) triples, you'll need to do
>> some pre-processing to fit a surface and produce the required inputs.
>>
>> Duncan Murdoch
>>
>>
>
>
> Tomáš Bayer
>   ,           ,
>  /             \
> ((__-^^-,-^^-__))
>  `-_---' `---_-'
>   `--|o` 'o|--'
>      \  `  /
>       ): :(
>       :o_o:
>        "-"
> GNU's Not Unix!
>
>



More information about the R-help mailing list