[R] metaMDS

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Sep 28 11:08:19 CEST 2011


On Fri, 2011-09-23 at 12:43 -0500, Jean V Adams wrote:
> Lineth Contreras wrote on 09/23/2011 11:35:10 AM:
> > 
> > Hello R-user community,
> > 
> > I am applying the function metaMDS. However, I would like to know if 
> there
> > is any option to export the data I got from the axis as a data frame.
> > 
> > I have tried as.data.frame.list but is not working.  Any suggestion?
> > 
> > Thank you in advance for your help,
> > 
> > Lineth
> 
> 
> When you say "the data I got from the axis" do you mean the coordinates 
> contained in the $points of the resulting object?  If so, something like 
> this should work (using the example provide in ?metaMDS):

You would be better off with the scores() method for metaMDS objects:

data(dune)
sol <- metaMDS(dune)
scrs <- scores(sol)

`scrs` is a matrix:

> class(scrs)
[1] "matrix"

which can be exported via say `write.csv()`:

write.csv(scrs, "filenames.csv")

If you want a data frame in R, then

SCRS <- as.data.frame(scrs)

will work, but there is little reason to convert to a data frame just to
export it out of R.

HTH

G

> data(dune)
> library(MASS)
> sol <- metaMDS(dune)
> df <- as.data.frame(sol$points)
> 
> Jean
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list