[R] How to export/save an "mrpp" object?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Fri Jan 7 17:56:00 CET 2011
On Fri, 2011-01-07 at 14:04 +0200, Nikos Alexandris wrote:
> Nikos:
>
> > > I finally ran mrpp tests. I think all is fine but one very important
> > > issue: I
> > > have no idea how to export/save an "mrpp" object. Tried anything I
> > > know and
> > > searched the archives but found nothing.
>
> David W:
>
> > And what happened when you tried what seems like the obvious:
>
> > save(mrpp_obj, file=)
> > # rm(list=ls() ) # Only uncomment if you are ready for your workspace
> > to clear
> > load("mrpp_store.Rdata")
>
> Right, "clearing" did the trick.
>
> > > Any ideas? Is really copy-pasting the mrpp results the only way?
> >
> > Many of us have no idea what such an object is, since you have not
> > described the packages and functions used to create it. If you want an
> > ASCII version then dput or dump are also available.
>
> Multiresponse Permuation Procedures (MRPP) is implemented in the "vegan"
> package. The function mrpp() returns (an object of class "mrpp") something
> like:
>
> --%<---
> # check class
> class ( samples_bitemporal_modis.0001.mrpp )
> [1] "mrpp"
>
> # check structure
> str ( samples_bitemporal_modis.0001.mrpp )
> List of 12
> $ call : language mrpp(dat = samples_bitemporal_modis.0001[, 1:5],
> grouping = samples_bitemporal_modis.0001[["Class"]])
> $ delta : num 0.126
> $ E.delta : num 0.202
> $ CS : logi NA
> $ n : Named int [1:5] 335 307 183 188 27
> ..- attr(*, "names")= chr [1:5] "Urban" "Vegetation" "Bare ground" "Burned"
> ...
> $ classdelta : Named num [1:5] 0.1255 0.1045 0.1837 0.0981 0.1743
> ..- attr(*, "names")= chr [1:5] "Urban" "Vegetation" "Bare ground" "Burned"
> ...
> $ Pvalue : num 0.001
> $ A : num 0.378
> $ distance : chr "euclidean"
> $ weight.type : num 1
> $ boot.deltas : num [1:999] 0.202 0.202 0.202 0.203 0.202 ...
> $ permutations: num 999
> - attr(*, "class")= chr "mrpp"
> -->%---
>
> Now I've tried the following:
>
> --%<---
> # 1. save(d) it
> save ( samples_bitemporal_modis.0001.mrpp , file="exported.mrpp.R" )
You would normally use the .R extension for R code not saved R objects.
instead, used .rda or .RData.
> # 2. loade(d) it in a new object...
> loadedmrpp <- load ( "exported.mrpp.R")
If you don't assign to output of load() then the
samples_bitemporal_modis.0001.mrpp object will end up in the global
workspace. If you assign the output, you store the strings of the
objects loaded, not the objects, which are still loaded into the global
workspace by default. This is stated in ?load:
Value:
A character vector of the names of objects created, invisibly.
> # 3. (tried) to check it...
> str ( "exported.mrpp.R")
>
> chr "samples_bitemporal_modis.0001.mrpp"
Hence the above, but I don't believe this. Surely you mean
`str(loadedmrpp)` but as I said this will only give the character string
of the names of the objects loaded...
> # it did not cross my mind immediately to...
> get(loadedmrpp)
...hence the above works, but what is wrong with simply typing
`samples_bitemporal_modis.0001.mrpp` (apart from the obvious - you must
enjoy typing to give objects such long names...).
I think you should read ?load to rethink what these functions do and how
they do it.
HTH
G
> Call:
> mrpp(dat = samples_bitemporal_modis.0001[, 1:5], grouping =
> samples_bitemporal_modis.0001[["Class"]])
>
> Dissimilarity index: euclidean
> Weights for groups: n
>
> Class means and counts:
>
> Urban Vegetation Bare ground Burned Water
> delta 0.1255 0.1045 0.1837 0.0981 0.1743
> n 335 307 183 188 27
>
> Chance corrected within-group agreement A: 0.3778
> Based on observed delta 0.1258 and expected delta 0.2022
>
> Significance of delta: 0.001
> Based on 999 permutations
>
> # ...or to work on a clean workspace!
> -->%---
>
> Thank you David. Cheers, Nikos
>
> ______________________________________________
> 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