[R] vector to matrix transformation
Gabor Grothendieck
ggrothendieck at myway.com
Sat Dec 4 04:12:51 CET 2004
If v is a vector, as.matrix(v) and t(v) give row and column
matrices and matrix(v,nrow=nr, ncol=nc) gives a matrix with
nr rows and nc columns such that the vector fills the first
column, then the second, etc. You only have to provide nr
or nc in most cases.
If m is a matrix c(m) is a vector formed by stringing out
the columns one after another. as.vector is similar.
Date: Fri, 3 Dec 2004 11:39:57 +0100
From: Gwenael Jacob <gwenael.jacob at wsl.ch>
To: <R-help at stat.math.ethz.ch>
Subject: [R] vector to matrix transformation
Dear,
Some analysis (linear regression) can only be
done from a vectorized dataset whereas others
require a matrix (Mantel tests). I use the two
analyses and thus need to format my data in
matrix and vector. I spent some time trying to
solve the problem and I just gave up. Did anyone
knows how to transform a matrix into a vector and
back-transform a vector into a matrix?
Thanks by advance,
GwenaÃ«l Jacob
--
-------------------------------------
GwenaÃ«l JACOB
Division Biodiversity
Swiss Federal Research Institute WSL
Zuercherstrasse 111/Postfach
CH-8903 Birmensdorf
SWITZERLAND
Phone : ++41 1 7392 504
Fax : ++41 1 7392 215
More information about the R-help
mailing list