5 Fri Sept 18: Protection Island 1

Today's exercise will be challenging. You should aim to complete this exercise before the next class. This exercise is due by Fri Sept 25. There will be a lot of carryover to the next exercise.

The information below is taken from the following source: Newcomb, HR. 1940. Ring-necked pheasant studies on Protection Island in the Strait of Juan de Fuca, Washington. MS thesis. Oregon State University.

  1. Pheasant chicks are born during the summer.
  2. In May 1937, 10 pheasants were introduced to the island. Before the next breeding season there were 35 pheasants.
  3. November 10, 1938 a census estimated 110 pheasants.
  4. October 13, 1939 a census estimated 400 pheasants.

5.1 Questions

  1. Read and complete all the exercises in Chapters 4.3 Variables and assignment to 4.10 R packages and 9 Making graphs in R of Quantitative skills for biology
  • Answer all questions marked HAND IN in the reading [5 marks]
  1. To make a graph of the data listed in b.-d., we need to learn how to work with dates. We will consider two possible approaches:
  1. Use a built-in R function to convert dates to a format that can be plotted (todays class); and

  2. Convert the dates to number of days since a reference date. Now the dates are numbers and these values can be plotted on the x-axis of a graph (next class).

In this question, we will proceed with option i. The function we will use is as.Date(). You can learn how to use this function using an internet search or by typing the following into your Console:

?as.Date

These files can be difficult to understand (see R Help files. A good way to proceed is to experiment with the function in the Console. Try these:

as.Date(2012-01-31, format = %Y-%m-%d)
as.Date("2012-01-31", format = "%Y-%m-%d")

Note that only the second command is error-free. The first command fails because the date argument for the as.Date() function must be a character string, i.e., must be enclosed in "" (see ?character).

It is also possible to omit the format argument and just code: as.Date("2012-01-31"). The help file notes that when the format argument is not specified, that formats will be tried one by one and an error will be returned if none work. It is advisable to specify the format, as allowing the function to infer the format could introduce errors.

Chapter 6.9 Data structures describes how to make a vector (note a vector is a list of numbers rather than just a single number). We need to make a vector of the dates so that we can make our plot. For example,

x <- as.Date(c("2012-01-31", "2012-03-05", "2013-01-11"), format = "%Y-%m-%d")

Having completed Chapter 11 Making graphs in R, and having learned how to work with dates, you should now be able to write an R script to make plot using the information in b.-d. above.

HAND IN

  • A graph and figure caption. The graph should have dates on the x-axis and the pheasant population size on the y-axis drawing from the information provided in b.-d. You will need to guess the date of 'before the breeding season' as stated in b. and you should disclose the value of this guess in the figure caption. See 1.7.1 for more information. The solutions to this problem have figure caption that is 2 sentences long. [Note that the graph will likely have years, not months on the x-axis - changing this is a quite fiddle-y and not worth it at this stage of your R journey] [10 marks]

  • An R Script that produces the figure described above. See 1.7.2 for more information. [5 marks]