Not sure it would be any smarter, but what about:

a <- c(5.78, 5.79,5.86)
n <- 10
matrix(rep(a,each=n), nrow=n)

That way, it would be easy to build a function with 'a' and 'n' as arguments.

HTH,
Ivan

--
Ivan Calandra, PhD
Scientific Mediator
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
--
https://www.researchgate.net/profile/Ivan_Calandra
https://publons.com/author/705639/

Le 01/08/2016 à 11:27, roslinazairimah zakaria a écrit :
Dear r-users,

I have a set of numbers that I would like to repeat for let say 10 times
and each number is repeated by vertically.

I tried this:

a <-  c(5.78, 5.79,5.86)
tran_a <- t(matrix(rep.int(a, 10),3))
dput(tran_a)

structure(c(5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78, 5.78,
5.78, 5.79, 5.79, 5.79, 5.79, 5.79, 5.79, 5.79, 5.79, 5.79, 5.79,
5.86, 5.86, 5.86, 5.86, 5.86, 5.86, 5.86, 5.86, 5.86, 5.86), .Dim = c(10L,
3L))

Or is there any smarter way?

Best regards,

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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