[R] vector to matrix transformation
Andy Bunn
abunn at whrc.org
Fri Dec 3 14:40:12 CET 2004
In addition to Sean's reply look at ?dist and other ways of creating
distance / similarity matrices for applications like Mantels Test. Package
vegan might be particularly useful.
HTH, Andy
R > x <- rnorm(10)
R > y <- dist(x)
R > str(x)
num [1:10] -0.431 0.564 0.901 -1.407 -0.991 ...
R > str(y)
Class 'dist' atomic [1:45] 0.995 1.332 0.977 0.560 0.909 ...
..- attr(*, "Size")= int 10
..- attr(*, "Diag")= logi FALSE
..- attr(*, "Upper")= logi FALSE
..- attr(*, "method")= chr "euclidean"
..- attr(*, "call")= language dist(x = x)
R > class(y)
[1] "dist"
R > class(x)
[1] "numeric"
R >
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Gwenael Jacob
> Sent: Friday, December 03, 2004 5:40 AM
> 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
>
> ______________________________________________
> 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
>
More information about the R-help
mailing list