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 <[EMAIL PROTECTED]>
To:   <[EMAIL PROTECTED]> 
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

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to