[R] I think a simple question

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Nov 13 00:32:15 CET 2006


"Leeds, Mark (IED)" <Mark.Leeds at morganstanley.com> writes:

> I have index ( of a vector ) values of say
> 
> tempin<-c(1 31 61   91 121     all the way upto 1411)
> 
> What I want is a function that takes in a number say, x = 5, and gives
> me an new vector
> of
> 
> tempout<-1  6 31  36 91  96  121  126  .......... 1411   1416
> 
> This can't be so hard but I can't get it and I've honestly tried.
> Obviously, tempin + 5 gives me the missing values but I don't know how
> to interwine them in the order above. Thanks for any help
> you can provide.

One way is

 c(rbind(tempin,tempin+5))

another is

 rep(tempin, each=2) + c(0,5)


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list