[R] Repeat matrices

roslinazairimah zakaria roslinaump at gmail.com
Mon Aug 1 11:27:35 CEST 2016


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,
-- 
*Dr. Roslinazairimah Binti Zakaria*
*Tel: +609-5492370; Fax. No.+609-5492766*

*Email: roslinazairimah at ump.edu.my <roslinazairimah at ump.edu.my>;
roslinaump at gmail.com <roslinaump at gmail.com>*
Deputy Dean (Academic & Student Affairs)
Faculty of Industrial Sciences & Technology
University Malaysia Pahang
Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia

	[[alternative HTML version deleted]]



More information about the R-help mailing list