[R] Populate a matrix

fernando.cabrera at nordea.com fernando.cabrera at nordea.com
Wed Oct 5 18:11:18 CEST 2011


Hi guys

I have vectors x <- c(1,2,3,4) and y <- c(4,3,9) and would like to generate a matrix which has 3 rows (length(y)) and 4 columns (length(x)), and each row is the corresponding y element repeated length(x) times.

4,4,4,4
3,3,3,3
9,9,9,9

Thanks.

Fernando Álvarez



More information about the R-help mailing list