[R] Help with rep

Gabor Csardi csardi at rmki.kfki.hu
Fri Jul 25 11:18:03 CEST 2008


Jacob, yes, e.g.

rep( c(4,3,4,2,3,4,1,2,3,4), 1 ) :)

Seriously, your question reminds me of (rather silly) television
contents, when one should find _the_ rule in a series of numbers. :)

Here is a solution, assuming I've found the "correct" rule:

unlist(lapply(4:1, seq, 4))

Best,
Gabor

On Fri, Jul 25, 2008 at 11:07:00AM +0200, Van Wyk, Jaap wrote:
> Hi
> Is it possible to use the rep command (or maybe some other "shortcut") to create a vector with the following format:
> 4  3  4  2  3  4  1  2  3  4
>  
> Any help is much appreciated.
> Thanks
> Jacob
>  
>  
> Jacob L van Wyk
> Department of Statistics
> University of Johannesburg, APK
> Box 524
> Auckland Park 2006
> South Africa
> Office Tel: +27 11 559 3080
> Fax: +27 11 559 2832
>  
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org 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.

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    UNIL DGM



More information about the R-help mailing list