Re: [R] generating sequences with gaps

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 26 Jul 2006 - 11:30:33 EST

Here are a few possibilies:

x <- c(4, 12, 20)

rep(x, each = 3) + 0:2

rep(x, each = 3) + sequence(rep(3, length(x))) - 1

c(sapply(x, seq, length = 3))

On 7/25/06, etienne <etiennesky@yahoo.com> wrote:
> I need sequences that have gaps in them, such as the
> following:
>
> 4 5 6 | 12 13 14 | 20 21 22
>
> a simple question, I've been scratching my head for a
> R function that will do this
>
> The : and seq do not allow this, and the c() can be
> used although not in an automatic way. I'm sure there
> is a way to do it without using a for() construct.
>
> Thank you
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



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 and provide commented, minimal, self-contained, reproducible code. Received on Wed Jul 26 12:45:03 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 26 Jul 2006 - 14:27:21 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.