On 09-12-2013, at 08:04, Arnaud Michel <michel.arn...@cirad.fr> wrote:

> Dear R Users
> 
> I have the vector
> X <- c( 6 , 4 ,12 , 3)
> 
> I would like to build a new vector by to transform it into
> Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4]))
> 
> Have you a more elegant answer ?


Have a good read of ?rep.

Try this:

rep(X,times=X)

Berend

______________________________________________
R-help@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.

Reply via email to