Re: [R] repeated vector in matrix

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Thu 02 Jun 2005 - 22:23:30 EST

try this:

h <- rep(3:2, c(4, 3))
############
n <- 10
matrix(rep(h, n), nrow = n, byrow = TRUE)

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


> Hallo,
>
> I'll need a matrix with n rows of the an identical vector.
>
>
>
>> h
> [1] 3 3 3 3 2 2 2
>
>
> The nmatrix should look like this:
>
>> x<-rbind(h,h,h)
>> x
> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> h 3 3 3 3 2 2 2
> h 3 3 3 3 2 2 2
> h 3 3 3 3 2 2 2
>
>
>
> but I need n rows which must be variable. Can anyone help me?
>
> thanks Andreas
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 02 22:33:19 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:21 EST