[R] Duplicate elements of a vector

2011-10-06 Thread syrvn
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

Re: [R] Duplicate elements of a vector

2011-10-06 Thread R. Michael Weylandt
rep(c(1,5,23), each=2) On Thu, Oct 6, 2011 at 2:58 PM, syrvn ment...@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:

Re: [R] Duplicate elements of a vector

2011-10-06 Thread Dimitris Rizopoulos
Check function rep(), e.g., rep(c(1, 5, 23), each = 2) I hope it helps. Best, Dimitris On 10/6/2011 8:58 PM, syrvn 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,

Re: [R] Duplicate elements of a vector

2011-10-06 Thread syrvn
thanks guys! I also found this solution but I think yours is better. as.vector(rbind(c(1, 5, 23))) Cheers syrvn -- View this message in context: http://r.789695.n4.nabble.com/Duplicate-elements-of-a-vector-tp3879561p3879907.html Sent from the R help mailing list archive at Nabble.com.