Spatial Data Analysis in Ecology and Agriculture using R

Return

If you have a question about something in the book, please send it to me at the email address on my home page. I will post the question (anonymously) along with an answer.

Question

I downloaded the data and R code for the book. When I look at the R code, the code tries to access directories "created" and "auxiliary", for example:

read.csv("created\\set4.2yld96cleaned.csv", ...
readShapePoly("auxiliary\\set4.1thiessen.shp")

These aren't available in the download data zip file. Are they missing, or did I not understand something?

Answer

The directories created and auxiliary must be created by you, the user, as subdirectories of your main data directory. The directory created holds files that you create in the process of analyzing the data. See page 36 for an example of its use. The directory auxiliary holds files that you either create yourself or download from the Internet. The specific example in your question refers to code that was used to produce Fig. 4.2 on page 110. I wanted the map that figure to have the same trapezoidal shape as the actual field, and R currently does not provide this (at least not very easily). Therefore I created the shapefile Set4.1thiessen.shp in ArcGIS, which does have this capacity. I put this file in the auxiliary subdirectory. I should mention that you can create in R a shapefile with a rectangular shape that is topologically equivalent and will give you the same result but not as pretty a map. See Section 3.5.3. Another example of the use of the auxiliary directory is given on page 217, in which data downloaded from the Internet are put in this directory.

SUPPLEMENT

Becasue of repeated requests, I have made these data available. I encourage you, however, to try to create the data yourself as well.

Question

Your code to produce the maps in Fig. 7.3 creates maps with the legend to the right, but in the actual figure, the legends are inside the map region. How was this done?

Answer

Unknown to me, the publisher made this modification in the figure. It is a good idea, however, and in the Supplementary Material on this site I have provided code to do it using R.

Question

In section 2.6.1 on page 40 there is a reference made to an array called "error.rate" which I have not been able to find. That array is used in several other places in the book. Am I missing something? Please direct me to the "error.rate" array.

Answer

I'm sorry this wasn't expressed more clearly in the text. The discussion of plotting in Section 2.6.1 "looks ahead" to the creation in Section 3.5.1 of a plot (Fig. 3.6) of a quantity called the error rate against a particular parameter. The array "error.rate," which represents the error rate, is found in the R code accompanying that Section, namely the file 3.5.1.r. The lines of code discussed in Section 2.6.1 are taken from this file. This same "look ahead" approach is also used with other plots discussed in Section 2.6.