[R] interpolation issue

Petr Savicky savicky at cs.cas.cz
Wed Apr 18 15:39:33 CEST 2012


On Wed, Apr 18, 2012 at 03:55:07AM -0700, uday wrote:
> This moment I got stuck with one interpolation issue
> the sample data which I have is as follows
> 
> pre1  <- c(10.34615 , 52.02116, 146.17357, 243.28644, 347.41504, 431.67105,
> 521.42712, 629.00446 ,729.95941,                            827.86279,
> 921.55078, 956.44446) 
> pre2  <- c( 983.4477692, 973.6199013, 958.0722141, 938.8194208 ,915.1833983,
> 852.1671089, 765.0037479,                                  654.0372907,
> 526.7369169, 397.0581990, 279.9788079, 229.5127059,185.2578164 ,147.2534510 
> ,115.1949457,  88.5712513,  66.7337287,  49.0140828, 23.3535195 , 
> 0.6609724) 
> 
> I have tried approx function
> approx(pres, sci.pre)
> Error in xy.coords(x, y) : 'x' and 'y' lengths differ 

Hi.

What is "pres" and "sci.pre"? Probably, they are vectors of
different lengths and they were interpreted as "x" and "y"
in approx(), see ?approx. If "sci.pre" should be "xout" in
approx(), then you have to specify some "y".

The vectors "pre1" and "pre2" have lengths 12 and 20, but
their relationshiop to "pres" and "sci.pre" is not clear.

Petr Savicky.



More information about the R-help mailing list