[R] Duplicate elements of a vector

R. Michael Weylandt michael.weylandt at gmail.com
Thu Oct 6 21:03:14 CEST 2011


rep(c(1,5,23), each=2)

On Thu, Oct 6, 2011 at 2:58 PM, syrvn <mentor_ at gmx.net> wrote:
> Hi,
>
> let's assume I have the following vector a:
>
> 1 5 23
>
> How can I use R to duplicate the elements so that my new vector looks like:
>
> 1 1 5 5 23 23
>
>
> Many thanks,
> Syrvn
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Duplicate-elements-of-a-vector-tp3879561p3879561.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list