[R] repeated vector in matrix

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Jun 2 14:21:36 CEST 2005


Friedrich, Andreas (dit) wrote:

> 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?


   x <- matrix(h, nrow = n, ncol = length(h), byrow = TRUE)

Uwe Ligges

> thanks Andreas
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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




More information about the R-help mailing list