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

From: Michael Bach <phaebz_at_gmail.com>
Date: Fri, 18 Mar 2011 15:14:30 +0200

Thank you very much Duncan, I sorted it out. Your advice helped me to be sure about the column range so I could track down my error.

For anyone who is interested: Inside my plot meta script I reference the arg x column as M[[x]]. It turned out that the other data set used slightly different column headers. This caused M[[x]] to evaluate to NULL which in turn triggered the "scales of x and y are too dissimilar" since there is indeed no scale whatsoever in NULL.

On Fri, Mar 18, 2011 at 1:21 PM, Duncan Murdoch <murdoch.duncan_at_gmail.com>wrote:

> 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.
>>
>
>

        [[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. Received on Fri 18 Mar 2011 - 13:17:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Mar 2011 - 13:20:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive