Hi mentor_, Try
c(sapply(vec[-1], function(x) c(vec[1], x))) # [1] 2 4 2 6 2 9 2 10 HTH, Jorge.- On Sun, Feb 12, 2012 at 12:54 PM, syrvn <> wrote: > Hello, > > > I am stuck with the following problem. Consider the vector: > > vec <- c(2,4,6,9,10) > > I now want to use R to manipulate the vector as follows: > > [1] 2, 4, 2, 6, 2, 9, 2, 10 > > In words, the first element of the vector should be placed in front of each > following number. > > Which R commands do I need to achieve that? > > > Cheers > > -- > View this message in context: > http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381586.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.