[R] vectors into a matrix
Henrique Dallazuanna
wwwhsd at gmail.com
Mon Jan 4 19:59:50 CET 2010
Try this:
cbind(ID = as.numeric(gsub("VD", "", ls(patt = "VD\\d+"))) ,
t(sapply(ls(patt = "VD\\d+"), get)))
On Mon, Jan 4, 2010 at 3:32 PM, Victor Kyros <varenda44 at gmail.com> 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
>
> *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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list