Re: [R] append

From: jim holtman <jholtman_at_gmail.com>
Date: Sun 11 Dec 2005 - 02:20:17 EST

Here is a way:

x <- 1:10
mySeq <- c(42,42)
byTwo <- rep(seq(length(x) + 1), each=2)[1:length(x)] y <- lapply(split(x, byTwo), function(a){   c(a, mySeq)
})
unlist(y)

On 12/10/05, Judy Chung <cp3942@gmail.com> wrote:
>
> Dear R users:
>
> > append(1:5, 0:1, after=2)
> [1] 1 2 0 1 3 4 5
>
> If I want to repeat the appended value every 2 like the following:
> [1] 1 2 0 1 3 4 0 1 5
>
> How should I modify?
> Thank you for any help.
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sun Dec 11 02:34:59 2005

This archive was generated by hypermail 2.1.8 : Sun 11 Dec 2005 - 04:30:48 EST