[R] convert vector to matrix

Alberto Monteiro albmont at centroin.com.br
Wed Oct 4 23:55:00 CEST 2006


Gavin Simpson wrote:
> 
> Did you even try to use cbind on your vector? I guess not as,
> 
> > vec <- 1:10
> > mat <- cbind(vec)
> > mat
>
Why does mat remain a matrix instead of "losing" one dimension?
I am reading the FAQ at...
http://cran.us.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-
dimensions_003f
... and it seems that anything you do to mat should turn it back
into a one-dimensional vector.

Alberto Monteiro



More information about the R-help mailing list