Mysterious (to me) behaviour of cbind() on an envelope -- ASDAR ch. 7
On Fri, 3 Feb 2012, D G Rossiter wrote:
Dear r-sig-geo friends: I am working through ASDAR (Applied Spatial Data Analysis with R) book using the code and datasets on the book's website http://www.asdar-book.org/. In sppa_mod.R (code for Chapter 7) we are trying to bind a new column giving the point-pattern name to an object of class envelope:
Gresults <- rbind(envjap, envred, envcells) class(Gresults)
[1] "envelope" "fv" "data.frame"
Gresults <- cbind(Gresults, DATASET=rep(c("JAPANESE", "REDWOOD", "CELLS"), each=length(r)))
but somehow the newly-bound column does not get the assigned name 'DATASET', but is assigned the name 'y':
Thanks for noting this. I've updated the online code to give the variable the name "y" instead of "DATASET" here, and in the F and K tests too. An erratum has also been added. The figures now show the envelopes as on book figures 7.3, 7.4 and 7.9. There was a further infelicity in that lpolygon() takes a col= rather than a fill= argument, changed in the online code for the figures. Best wishes, Roger
str(Gresults)
Classes 'fv' and 'data.frame': 144 obs. of 6 variables: $ r : num 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 ... $ obs : num 0 0 0 0.0615 0.0615 ... $ theo: num 0 0.00509 0.02021 0.04491 0.07843 ... $ lo : num 0 0 0 0 0 ... $ hi : num 0 0.0625 0.0748 0.1427 0.1933 ... $ y : Factor w/ 3 levels "CELLS","JAPANESE",..: 2 2 2 2 2 2 2 2 2 2 ... .... somehow the envelope has been removed also. Then when I try to plot according to the following code:
print(xyplot(obs~theo|DATASET , data=Gresults, type="l", ...
the classifying category is not found. If I replace DATASET with y the plot is shown as in Fig. 7.3. Clearly the cbind() is somehow not preserving the assigned column name, despite the class being build on data.frame. Where it gets the 'y' from is also seriously mysterious to me. Here's my version info. I started from a clean workspace and only loaded the packages as indicated.
version
platform x86_64-apple-darwin9.8.0 arch x86_64 os darwin9.8.0 system x86_64, darwin9.8.0 status major 2 minor 14.0 year 2011 month 10 day 31 svn rev 57496 language R version.string R version 2.14.0 (2011-10-31) Package: sp Version: 0.9-94 Date: 2011-12-21 Package: spatstat Version: 1.25-2 Date: 2012-01-19 Thanks for any insight! D. G. Rossiter Senior University Lecturer University of Twente, Faculty ITC Hengelosestraat 99 PO Box 217, 7500 AE Enschede, the Netherlands (NL) Phone: +31-(0)53 4874 499 Fax: +31-(0)53 4874 336 mailto:rossiter at itc.nl, Internet: http://www.itc.nl/personal/rossiter Faculty of Geo-Information Science and Earth Observation (ITC) University of Twente Chamber of Commerce: 501305360000 E-mail disclaimer The information in this e-mail, including any attachments, is intended for the addressee only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or action in relation to the content of this information is strictly prohibited. If you have received this e-mail by mistake, please delete the message and any attachment and inform the sender by return e-mail. ITC accepts no liability for any error or omission in the message content or for damage of any kind that may arise as a result of e-mail transmission.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no