[R] vector to matrix transformation
Petr Pikal
petr.pikal at precheza.cz
Fri Dec 3 13:16:36 CET 2004
On 3 Dec 2004 at 11:39, Gwenael Jacob wrote:
> 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
Hi Gwenael
You probably gave up too early
did you read ?as.matrix, ?as.vector
> x<-matrix(1:6,3,2)
> x
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> as.vector(x)
[1] 1 2 3 4 5 6
> y<-as.vector(x)
> z<-matrix(y,3,2)
> z
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
Cheers
Petr
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
Petr Pikal
petr.pikal at precheza.cz
More information about the R-help
mailing list