[R] interpolation

David Winsemius dwinsemius at comcast.net
Mon Jan 11 14:43:12 CET 2010


On Jan 11, 2010, at 7:44 AM, René Mayer wrote:

> Dear R-users,
> I have a complex line by xy-values (ordered by z).
> And I would like to get interpolated y-values on the positions of x  
> = 0:600.
> How do I get the correct points?
>
> x 
> = 
> c 
> (790,790,790,790,790,786,783,778,778,766,763,761,761,761,715,628,521,350,160,134,134,129,108,101,93,111,161,249,288,243,139,45,7 
> )
>
> y 
> = 
> c 
> (606,606,606,606,606,612,617,627,627,640,641,641,641,641,689,772,877,1048,1240,1272,1272,1258,1242,1239,1239,1214,1122,959,770,479,273,133,45 
> )
>
> z 
> = 
> c 
> (0,29,58,87,116,145,174,203,232,261,290,319,348,377,406,435,464,493,522,551,580,609,638,667,696,725,754,783,812,841,870,899,928 
> )
>
>
> plot(y,x,type="b")

That would plot x as a function of y (the reverse of the usual  
convention. Is that what you want. If so, then the statement that  
these are ordered by z is misleading. Ordering by z would suggest that  
each series is a function of z. What sort of interpolation do you want  
and in how many dimensions?

>
> # this fails ?????
> lines(approx(y,x),col="blue") # with xout = c(0:600)
>
> thanks in advance,
> René
>
>
>
> -- 
> Dr. rer. nat. Dipl.-Psych. René Mayer
>
> Dresden University of Technology
> Department of Psychology
> Zellescher Weg 17
> D-01062 Dresden
>
> Tel.: +49-351-4633-4568
>
> Email: mayer at psychologie.tu-dresden.de
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list