[R] How to generate a matrix where each row (or column) is the same vector?
Henrique Dallazuanna
wwwhsd at gmail.com
Thu Sep 17 16:16:49 CEST 2009
Or:
replicate(5, 1:10)
On Thu, Sep 17, 2009 at 11:02 AM, Peng Yu <pengyu.ut at gmail.com> wrote:
> Hi,
>
> I can use the following code to generate a matrix, each column of
> which is 'x'. But I have to specify '5' twice in the second command. I
> am wondering if there is a better way to do it.
>
>> x=1:10
>> matrix(rep(x,5),nc=5)
>> t(matrix(rep(x,5),nc=5))
>
> Regards,
> Peng
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list