[R] vectors into a matrix

David Winsemius dwinsemius at comcast.net
Mon Jan 4 19:13:49 CET 2010


On Jan 4, 2010, at 12:32 PM, Victor Kyros wrote:

> Dear all,
>
> I'm writing code to do automatically several
> calculations and gather the results in a matrix.
>
>
> I have the following vectors and
> I just want to make a matrix with them:
>
> VD1
> VD2
> VD3
> ...
> VD12
>

cbind( 1:12, matrix(c(VD1, ..., VD12), nrow=12, byrow=TRUE) )

> *In this case, this series of vectors stops there, in 12,
> but it could be a higher number or smaller.
> (for example: VD1, VD2 and VD3; only)
> (or for example: VD1, VD2, ... till VD78)
>
> All vectors have the same length, 9.
> And vectors should be entered by row.
> Besides, I would like to add a column with the number of the vector.
>
> Something like this:
>
> 1     44    23    0.3    ...
> 2     51    27    0.8    ...
> 3     40    24    0.6    ...
> 4     47    18    0.2    ...
> 5     52    30    1.2    ...
> ...   ...   ...   ...    ...
> 12    39    22    0.5    ...
>
>
> I hope I've explained myself good enough.
> Thanks in advance for taking the time to help me.
>
> Vilen
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list