About the Authors |
|
xv | |
Preface |
|
xix | |
Acknowledgements |
|
xxxi | |
|
|
1 | (2) |
|
|
1 | (1) |
|
Running Code as You Go Along |
|
|
1 | (1) |
|
|
2 | (1) |
|
2 Installing and Running R |
|
|
3 | (6) |
|
Downloading and Installing R onto Your Computer |
|
|
3 | (4) |
|
|
7 | (2) |
|
|
9 | (4) |
|
4 First Simple Programs and Graphics |
|
|
13 | (18) |
|
|
13 | (1) |
|
Commas, Brackets and Concatenation |
|
|
14 | (1) |
|
|
15 | (1) |
|
Raise to the Power of Symbol |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
Beginning with Simple R Code to Get Used to the Command Line System |
|
|
16 | (3) |
|
|
19 | (4) |
|
Working with Character Variables |
|
|
23 | (4) |
|
|
27 | (1) |
|
|
27 | (1) |
|
|
28 | (3) |
|
|
31 | (6) |
|
Combining Sets of Tables for Data Collected on Different Dates |
|
|
34 | (1) |
|
Converting Factors in a Dataframe to Numeric or Character |
|
|
34 | (3) |
|
6 Plotting Biological Data in Various Ways |
|
|
37 | (42) |
|
Example 1 Bryophytes up a Mountain |
|
|
37 | (4) |
|
|
41 | (2) |
|
Adding a Legend to a Plot |
|
|
43 | (2) |
|
Troubleshooting 2 - Vector Lengths Differ |
|
|
45 | (1) |
|
Troubleshooting 3 - Missing Data and NAs |
|
|
46 | (2) |
|
Incorporating More Types of Data on the Same Graph |
|
|
48 | (1) |
|
Example 2 Tropical Forests, Rural Population, Logarithmic Axes and Installing Packages |
|
|
49 | (3) |
|
Example 3 Creating a Barplot: Bryophytes Side-by-side |
|
|
52 | (1) |
|
Example 4 Stacked Bar Chart, with Different Colours, Fills and Legends |
|
|
53 | (4) |
|
Example 5 Dietary Differences between Hornbill Species - Entering Data as a Table |
|
|
57 | (3) |
|
Example 6 Horizontal Bar Plot of Camera Trap Data and More Troubleshooting |
|
|
60 | (2) |
|
Example 7 Adding Error Bars to a Barplot or Plot: Fly Ommatidea |
|
|
62 | (2) |
|
Example 8 Creating Pie Charts Using pie and circlize |
|
|
64 | (5) |
|
Example 9 Fish Metacercarial Load and Box and Whisker Plots |
|
|
69 | (4) |
|
Adding Notches to a Boxplot |
|
|
73 | (1) |
|
Tukey's Honest Significant Difference Test |
|
|
74 | (5) |
|
7 The Grammar of Graphics Family of Packages |
|
|
79 | (6) |
|
|
85 | (10) |
|
9 Statistics: Choosing the Right Test |
|
|
95 | (8) |
|
Explanatory and Response Variables, Experiments and Surveys |
|
|
97 | (1) |
|
Parametric versus Non-parametric Tests |
|
|
98 | (1) |
|
Difference between Linear Models and Generalized Linear Models |
|
|
98 | (4) |
|
Our Basic Aim Is to Achieve a Near-linear QQ Plot and Even Variance |
|
|
102 | (1) |
|
10 Commonly Used Measures and Statistical Tests |
|
|
103 | (16) |
|
Normality, Skew and Kurtosis |
|
|
103 | (1) |
|
Testing Whether Proportions Agree with Null Expectations |
|
|
104 | (2) |
|
The Special Case of Contingency Tables |
|
|
106 | (1) |
|
Hardy-Weinberg Equilibrium |
|
|
107 | (3) |
|
Alternatives to the Chi-squared Test under Some Circumstances |
|
|
110 | (1) |
|
Testing Whether Two Means Are Significantly Different |
|
|
111 | (1) |
|
|
111 | (1) |
|
|
112 | (1) |
|
|
113 | (1) |
|
Testing Whether Three or More Means Differ from One Another |
|
|
113 | (1) |
|
|
114 | (1) |
|
Non-normally Distributed Data with Small Sample Sizes - Mann-Whitney U Test |
|
|
114 | (2) |
|
Non-parametric Two-sample Tests |
|
|
116 | (1) |
|
|
117 | (2) |
|
11 Regression and Correlation Analyses |
|
|
119 | (28) |
|
Linear versus Non-linear Regression |
|
|
120 | (1) |
|
Log-log Plot Example Correlation of Numbers of Species with Area |
|
|
121 | (2) |
|
Linearizing Data with No Known Underlying Model |
|
|
123 | (2) |
|
Errant Points and Leverage |
|
|
125 | (4) |
|
QQ Model Plot from the car Library |
|
|
129 | (1) |
|
Comparing Regression Slopes and Intercepts Using t-test |
|
|
130 | (4) |
|
|
134 | (3) |
|
|
137 | (1) |
|
Hairwise riots ot txplanatory Variables to Visually Inspect Interactions |
|
|
138 | (2) |
|
Polynomial Regression and Model Simplification |
|
|
140 | (3) |
|
|
143 | (4) |
|
12 Count Data as Response Variable |
|
|
147 | (8) |
|
Example 1 Fledgling Numbers in Relation to Clutch Initiation Date |
|
|
148 | (3) |
|
Example 2 Pollinator Flower Visits in Passiflora in Relation to Flower Size |
|
|
151 | (4) |
|
13 Analysis of Variance (ANOVA) |
|
|
155 | (11) |
|
Example 1 A One-way ANOVA, the InsectSprays Dataset |
|
|
155 | (2) |
|
Example 2 ANOVA with Proportion Data as Response Variable Using Arcsine Transformation |
|
|
157 | (6) |
|
Example 3 Analysis with Proportion Data as Response Variable Using Logit Transformation |
|
|
163 | (3) |
|
14 Analysis of Covariance (ANCOVA) |
|
|
166 | (5) |
|
Example 1 Growth of Tagged Gobies |
|
|
166 | (2) |
|
Example 2 Fitting through the Origin and Count Data as Response Variable |
|
|
168 | (3) |
|
15 More Generalized Linear Modelling |
|
|
171 | (16) |
|
|
171 | (1) |
|
Binary Response Variable with One Continuous Explanatory Variable |
|
|
172 | (1) |
|
Example 1 Logistic regression of gall former predation |
|
|
172 | (4) |
|
|
176 | (1) |
|
Example 2 Pollinator counts - showing importance of deviance |
|
|
177 | (5) |
|
Example 3 Proportion data with N known |
|
|
182 | (5) |
|
16 Monte Carlo Tests and Randomization |
|
|
187 | (7) |
|
Random Number Generator Code |
|
|
187 | (1) |
|
Example 1 Flower Visits by Thai Honey Bee Species |
|
|
188 | (3) |
|
Randomizing Cells in a Matrix |
|
|
191 | (3) |
|
17 Principal Components Analysis |
|
|
194 | (6) |
|
Example 1 Rock Oyster Allozymes |
|
|
194 | (3) |
|
Example 2-The Iris Dataset |
|
|
197 | (3) |
|
18 Species Abundance, Accumulation and Diversity Data |
|
|
200 | (18) |
|
Species Accumulation Data |
|
|
200 | (2) |
|
Species Accumulation Curves and Randomization |
|
|
202 | (6) |
|
Species Richness Estimation |
|
|
208 | (1) |
|
Species Diversity Indices |
|
|
208 | (2) |
|
A Note to Be Cautious about Logarithms in Functions |
|
|
210 | (1) |
|
|
211 | (3) |
|
A Much Faster Approach Using Vectorization |
|
|
214 | (4) |
|
|
218 | (9) |
|
Example 1 Survival of Killdeer Nests |
|
|
218 | (9) |
|
20 Dates and Julian Dates |
|
|
227 | (13) |
|
Problem with Two-digit Dates and POSIX: A Date of Burial Example |
|
|
232 | (2) |
|
Phenology and the density Function |
|
|
234 | (2) |
|
Extracting Day and Month from Julian Days |
|
|
236 | (2) |
|
Seasonal Patterns and Other Smoothing Curves |
|
|
238 | (2) |
|
21 Mapping and Parsing Text Input for Data |
|
|
240 | (17) |
|
Creating Our Own Map from Digitized Coordinates |
|
|
247 | (10) |
|
22 More on Manipulating Text |
|
|
257 | (18) |
|
Example 1 Standardizing Names in a Phylogenetic Tree Description |
|
|
257 | (2) |
|
|
259 | (3) |
|
Method 2 Based on Fixed Character String Length |
|
|
262 | (1) |
|
Method 3 Using a Vector of Positions |
|
|
262 | (2) |
|
Example 2 Substrings of Unknown Length |
|
|
264 | (4) |
|
Trimming White Spaces and/or Tabs |
|
|
268 | (1) |
|
Using Wildcards to Locate Internal Letter Strings |
|
|
268 | (1) |
|
Finding Suffixes, Prefixes and Specifying Letters, Numbers and Punctuation |
|
|
269 | (2) |
|
Manipulating Character Case |
|
|
271 | (1) |
|
|
272 | (1) |
|
Specifying Particular and Modifiable Character Classes |
|
|
273 | (2) |
|
|
275 | (9) |
|
|
279 | (1) |
|
|
280 | (1) |
|
Different Types of Plots in ape |
|
|
281 | (3) |
|
24 Working with DNA Sequences and Other Character Data |
|
|
284 | (13) |
|
Sequential Runs of Base Types |
|
|
288 | (2) |
|
Downloading DNA Sequences from GenBank |
|
|
290 | (2) |
|
Translating DNA to Amino Acids |
|
|
292 | (1) |
|
|
293 | (2) |
|
Easy Ways to Extract Taxon Names from a Phylogenetic Matrix |
|
|
295 | (1) |
|
Replacing Specified Ambiguity Codes with a Question Mark |
|
|
296 | (1) |
|
25 Spacing in Two Dimensions |
|
|
297 | (6) |
|
26 Population Modelling Including Spatially Explicit Models |
|
|
303 | (23) |
|
Example 1 Ricker Population Growth Model, Plotting as You Go |
|
|
303 | (3) |
|
Example 2 Host-Parasitoid Population Modelling - Discrete Time Version |
|
|
306 | (4) |
|
Example 3 Spatial Host-Parasitoid Model |
|
|
310 | (8) |
|
Example 4 Genetic Drift, a Program Aimed at Teaching Students about Evolution |
|
|
318 | (4) |
|
27 More on apply Family of Functions - Avoid Loops to Get More Speed |
|
|
322 | (1) |
|
|
323 | (1) |
|
Using tapply to Calculate Values Based on Factors |
|
|
324 | (2) |
|
28 Food Webs and Simple Graphics |
|
|
326 | (6) |
|
A Parasitoid foodweb Example |
|
|
326 | (2) |
|
Foodweb and Community Packages |
|
|
328 | (4) |
|
|
332 | (3) |
|
30 Standard Distributions in R |
|
|
335 | (13) |
|
|
335 | (3) |
|
|
338 | (2) |
|
|
340 | (1) |
|
|
341 | (1) |
|
|
342 | (1) |
|
|
343 | (1) |
|
The Chi-squared Distribution |
|
|
344 | (4) |
|
31 Reading and Writing Data to and from Files |
|
|
348 | (9) |
|
Appending Data to an Existing File |
|
|
349 | (1) |
|
Using read.delim with Non-tab Separator |
|
|
350 | (1) |
|
Choosing a File to Read Interactively |
|
|
350 | (1) |
|
Using Excel for Data Entry |
|
|
351 | (1) |
|
The readxl Function and Tibbies |
|
|
352 | (2) |
|
Reading PDF Files for Data Mining |
|
|
354 | (1) |
|
Writing Graphics Directly to Disc |
|
|
354 | (3) |
|
Appendix 1 Summary of Graphical Parameters |
|
|
357 | (3) |
|
Arguments Passed Directly to par Function |
|
|
357 | (1) |
|
Arguments Applied Directly to the plot Function as well as in Some Others |
|
|
357 | (1) |
|
Arguments for the lines Function |
|
|
358 | (1) |
|
Having Multiple Graphics Windows Open at the Same Time |
|
|
358 | (1) |
|
Macintosh-specific Graphics |
|
|
359 | (1) |
|
Using the layout Function |
|
|
359 | (1) |
|
Using the split-screen Function |
|
|
359 | (1) |
|
Appendix 2 General Housekeeping R Functions and Others Not Covered in the Main Text |
|
|
360 | (4) |
|
General Housekeeping Functions |
|
|
360 | (1) |
|
Setting or Changing the Working Directory |
|
|
360 | (1) |
|
Finding What Files Are in a Directory |
|
|
361 | (1) |
|
Graphical Functions and Parameters |
|
|
361 | (1) |
|
|
361 | (1) |
|
|
361 | (1) |
|
Writing Concatenated Data Straight to File (in the Working Directory) Using cat |
|
|
362 | (1) |
|
Troubleshooting Package Installation |
|
|
362 | (2) |
|
Appendix 3 Some Useful Statistical and Mathematical Equations |
|
|
364 | (5) |
|
Logical Mathematical Operators |
|
|
364 | (1) |
|
|
364 | (1) |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
365 | (1) |
|
|
366 | (1) |
|
|
366 | (1) |
|
Weibull and Compertz Equations |
|
|
366 | (1) |
|
|
367 | (1) |
|
Convert Radians and Degrees Functions |
|
|
367 | (2) |
Bibliography |
|
369 | (6) |
Web Resources |
|
375 | (2) |
Index |
|
377 | |