[R] Interpolation Problems
Steve Murray
smurray444 at hotmail.com
Tue Sep 2 00:17:15 CEST 2008
Dear all,
I'm trying to interpolate a dataset to give it twice as many values (I'm giving the dataset a finer resolution by interpolating from 1 degree to 0.5 degrees) to match that of a corresponding dataset.
I have the data in both a data frame format (longitude column header values along the top with latitude row header values down the side) or column format (in the format latitude, longitude, value).
I have used Google to determine 'approxfun' the most appropriate command to use for this purpose - I may well be wrong here though! Nevertheless, I've tried using it with the default arguments for the data frame (i.e. interp <- approxfun(dataset) ) but encounter the following errors:
> interp <- approxfun(JanAv)
Error in approxfun(JanAv) :
need at least two non-NA values to interpolate
In addition: Warning message:
In approxfun(JanAv) : collapsing to unique 'x' values
However, there are no NA values! And to double-check this, I did the following:
> JanAv[is.na(JanAv)] <- 0
...to ensure that there really are no NAs, but receive the same error message each time.
With regard to the latter 'collapsing to unique 'x' values', I'm not sure what this means exactly, or how to deal with it.
Any words of wisdom on how I should go about this, or whether I should use an alternative command (I want to perform a simple (e.g. linear) interpolation), would be much appreciated.
Many thanks for any advice offered,
Steve
More information about the R-help
mailing list