[R] akima::interp "scales of x and y are too dissimilar"

Duncan Murdoch murdoch.duncan at gmail.com
Fri Mar 18 12:21:29 CET 2011

On 18/03/2011 6:37 AM, Michael Bach wrote:
> Dear R users,
> I want to do a fitted.contour plot of selected columns of a dataframe M with
> M$AM and M$Irradiance as x and y axes respectively. The level of the contour
> shall be determined by M$PR.
> Some words on my data first. Dataframe M looks like:
> head(M$Irradiance)
> [1] 293 350 412 419 477 509
> head(M$AM)
> [1] 2.407 2.161 1.964 1.805 1.673 1.563
> head(M$PR)
> [1] 70.102 72.600 75.097 80.167 79.644 82.633
> To create a grid, I used "interp" from the "akima" package up until now. As
> mentioned in the header, I run into problems when trying the following:
> grid<- akima::interp(M$AM,M$Irradiance,M$PR, duplicate="mean");
> Error in interp.old(x, y, z, xo = xo, yo = yo, ncp = 0, extrap = extrap,  :
>    scales of x and y are too dissimilar

The help page for interp says this:

" The triangulation scheme used by ‘interp’ works well if ‘x’ and
      ‘y’ have similar scales but will appear stretched if they have
      very different scales.  The spreads of ‘x’ and ‘y’ must be within
      four orders of magnitude of each other for ‘interp’ to work. "

So I would guess that your data is more variable than the first few 
values indicate:  I would look at range(M$AM) and range(M$PR).  It's 
possible that you have some bad values in there (e.g. 99999999999 as a 
missing code).

If all the data are fine, then you could just standardize the variables:

stdAM <- with(M, (AM - mean(AM))/sd(AM))

etc. to put things all on a standard scale.

Duncan Murdoch

> M$Irradiance constists mostly of 3 digit integers, whereas M$AM of decimal
> numbers.
> Now, is there another function like interp that can handle this? I could not
> find a clue in the doc. Should I look deeper into the doc? Maybe transform
> the y axis?
> Additionally, I was told in a previous post to include a working example. I
> do not know how to do that properly. Shall I post code to reproduce a
> similar data frame or even attach my csv file?
> Best Regards,
> Michael Bach
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list