just use rep(), e.g.,
x <- c(2, 4, 5)
N <- c(3, 1, 2)
rep(x, N)
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Anders Bj?rges?ter" <anders.bjorgesater at bio.uio.no>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, September 08, 2006 3:32 PM
Subject: [R] repeating values
> Hello
>
> I have 2 two vectors like
>
> x N
> 2 3
> 4 1
> 5 2
>
> and want to make a new vector
>
> x
> 2
> 2
> 2
> 4
> 5
> 5
>
> i.e. repeat the values in x according to N
>
>
> Thanks for your help.
>
> Best Regards
> Anders
>
> ______________________________________________
> R-help at 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.
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm