Eric C. Jennings wrote:
> To start with, pardon my mistake regarding "two vectors"
>
> Yes I want all values (to two decimal digits if I can) between each of
> the values given in the vector.
> meaning I'm really try to do something like this:
> y<- c(0.4 : 0.0 : 0.2 : -0.2 : 0.6 : 0.2 : 0.0 : 0.0 : 0.4 : 0.4 : 0.2)
> which of course does not work. (But on this point, something like m<-
> c(0.2:-0.6) doesn't work either.
>
Hi Eric,
Okay, what you probably want is:
seq(0.4,0.0,by=0.01*sign(0.0-0.4))
...
This can be worked into the function that I posted, but it's getting a
bit tricky to make it general. What you want to do is to "walk" through
the values creating a sequence between each one with the above call.
in.betweens<-function(x,increment) {
lenx<-length(x)
newx<-x[1]
for(i in 1:(lenx-1))
newx<-c(newx,seq(x[i],x[i+1],by=increment*sign(x[i+1]-x[i]))[-1])
return(zapsmall(newx))
}
Jim
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html