[R] values in between

Martin Maechler maechler at stat.math.ethz.ch
Thu Dec 1 09:18:26 CET 2005


>>>>> "Eric" == Eric C Jennings <matheric at u.washington.edu>
>>>>>     on Wed, 30 Nov 2005 21:39:12 -0800 writes:

    Eric> Hey there
    Eric> I have two vectors:

    Eric> y<- c(0.4,  0.0,  0.2, -0.2, -0.6, 0.2, 0.0, 0.0, 0.4, 0.4, 0.2)

hmm, this is *one* vector , not two !

    Eric> In the vector y, I want to access (in the order given) all of the values in 
    Eric> between each of the specific values of given.

    Eric> I understand subsetting with y[i], but how do I get to ssomewhere in 
    Eric> between -0.6 and 0.2?

Though you could be much clearer, in your question, I'm pretty
sure you are looking for  *interpolation*; 
In that case, I'd recommend  approx() or spline()  -- or with same
functionality but more elegant interface -- approxfun() and
splinefun().

Martin Maechler, ETH Zurich




More information about the R-help mailing list