Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover
Half Title
Title
Copyright
Dedication
Contents
About the Authors
Preface
Acknowledgements
1. How to Use This Book
Setting Up Your Computer
Running Code as You Go Along
Chapter Structure
2. Installing and Running R3
Downloading and Installing R onto Your Computer
Installing Packages
3. Very Basic R Syntax
4. First Simple Programs and Graphics
Basic R Features
Commas, Brackets and Concatenation
The Colon Character
Raise to the Power of Symbol
Exiting from R
Help Pages
Beginning with Simple R Code to Get Used to the Command Line System
Playing with Graphics
Working with Character Variables
Built-in R Datasets
The table Function
Ragged Data
5. The Dataframe Concept
Combining Sets of Tables for Data Collected on Different Dates
Converting Factors in a Dataframe to Numeric or Character
6. Plotting Biological Data in Various Ways
Example 1 – Bryophytes up a Mountain
Troubleshooting
Adding a Legend to a Plot
Troubleshooting 2 – Vector Lengths Differ
Troubleshooting 3 – Missing Data and NAs
Incorporating More Types of Data on the Same Graph
Example 2 – Tropical Forests, Rural Population, Logarithmic Axes and Installing Packages
Example 3 – Creating a Barplot: Bryophytes Side-by-side
Example 4 – Stacked Bar Chart, with Different Colours, Fills and Legends
Example 5 – Dietary Differences between Hornbill Species – Entering Data as a Table
Example 6 – Horizontal Bar Plot of Camera Trap Data and More Troubleshooting
Example 7 – Adding Error Bars to a Barplot or Plot: Fly Ommatidea
Example 8 – Creating Pie Charts Using pie and circlize
Example 9 – Fish Metacercarial Load and Box and Whisker Plots
Adding Notches to a Boxplot
Tukey’s Honest Significant Difference Test
7. The Grammar of Graphics Family of Packages
8. Sets and Venn Diagrams
9. Statistics: Choosing the Right Test
Explanatory and Response Variables, Experiments and Surveys
Parametric versus Non-parametric Tests
Difference between Linear Models and Generalized Linear Models
Our Basic Aim Is to Achieve a Near-linear QQ Plot and Even Variance
10. Commonly Used Measures and Statistical Tests
Normality, Skew and Kurtosis
Testing Whether Proportions Agree with Null Expectations
The Special Case of Contingency Tables
Hardy-Weinberg Equilibrium
Alternatives to the Chi-squared Test under Some Circumstances
Testing Whether Two Means Are Significantly Different
Single-sample t-test
Two-sample t-test
Paired t-test
Testing Whether Three or More Means Differ from One Another
Comparing Two Variances
Non-normally Distributed Data with Small Sample Sizes – Mann-Whitney U Test
Non-parametric Two-sample Tests
Binomial Test
11. Regression and Correlation Analyses
Linear versus Non-linear Regression
Log-log Plot Example Correlation of Numbers of Species with Area
Linearizing Data with No Known Underlying Model
Errant Points and Leverage
QQ Model Plot from the car Library
Comparing Regression Slopes and Intercepts Using t-test
Non-linear Regression
Multiple Regression
Pairwise Plots of Explanatory Variables to Visually Inspect Interactions
Polynomial Regression and Model Simplification
Model Simplification
12. Count Data as Response Variable
Example 1 – Fledgling Numbers in Relation to Clutch Initiation Date
Example 2 – Pollinator Flower Visits in Passiflora in Relation to Flower Size
13. Analysis of Variance (ANOVA)
Example 1 – A One-way ANOVA, the InsectSprays Dataset
Example 2 – ANOVA with Proportion Data as Response Variable Using Arcsine Transformation
Example 3 – Analysis with Proportion Data as Response Variable Using Logit Transformation
14. Analysis of Covariance (ANCOVA)
Example 1 – Growth of Tagged Gobies
Example 2 – Fitting through the Origin and Count Data as Response Variable
15. More Generalized Linear Modelling
Model Inspection
Binary Response Variable with One Continuous Explanatory Variable
Example 1 – Logistic regression of gall former predation
LD50s
Example 2 – Pollinator counts – showing importance of deviance
Example 3 – Proportion data with N known
16. Monte Carlo Tests and Randomization
Random Number Generator Code
Example 1 – Flower Visits by Thai Honey Bee Species
Randomizing Cells in a Matrix
17. Principal Components Analysis
Example 1 – Rock Oyster Allozymes
Example 2 – The Iris Dataset
18. Species Abundance, Accumulation and Diversity Data
Species Accumulation Data
Species Accumulation Curves and Randomization
Species Richness Estimation
Species Diversity Indices
A Note to Be Cautious about Logarithms in Functions
Broken-stick Models
A Much Faster Approach Using Vectorization
19. Survivorship
Example 1 – Survival of Killdeer Nests
20. Dates and Julian Dates
Problem with Two-digit Dates and POSIX: A Date of Burial Example
Phenology and the density Function
Extracting Day and Month from Julian Days
Seasonal Patterns and Other Smoothing Curves
21. Mapping and Parsing Text Input for Data
Creating Our Own Map from Digitized Coordinates
22. More on Manipulating Text
Example 1 – Standardizing Names in a Phylogenetic Tree Description
Method 1 with Wildcards
Method 2 Based on Fixed Character String Length
Method 3 Using a Vector of Positions
Example 2 – Substrings of Unknown Length
Trimming White Spaces and/or Tabs
Using Wildcards to Locate Internal Letter Strings
Finding Suffixes, Prefixes and Specifying Letters, Numbers and Punctuation
Manipulating Character Case
Ignoring Character Case
Specifying Particular and Modifiable Character Classes
23. Phylogenies and Trees
Branch Lengths
Random Trees
Different Types of Plots in ape
24. Working with DNA Sequences and Other Character Data
Sequential Runs of Base Types
Downloading DNA Sequences from GenBank
Translating DNA to Amino Acids
Prettifying a Table
Easy Ways to Extract Taxon Names from a Phylogenetic Matrix
Replacing Specified Ambiguity Codes with a Question Mark
25. Spacing in Two Dimensions
26. Population Modelling Including Spatially Explicit Models
Example 1 – Ricker Population Growth Model, Plotting as You Go
Example 2 – Host–Parasitoid Population Modelling – Discrete Time Version
Example 3 – Spatial Host–Parasitoid Model
Example 4 – Genetic Drift, a Program Aimed at Teaching Students about Evolution
27. More on apply Family of Functions – Avoid Loops to Get More Speed
Using apply
Using tapply to Calculate Values Based on Factors
28. Food Webs and Simple Graphics
A Parasitoid foodweb Example
Foodweb and Community Packages
29. Adding Photographs
30. Standard Distributions in R
The Normal Distribution
Student’s t Distribution
Lognormal Distribution
Logistic Distribution
Poisson Distribution
Gamma Distribution
The Chi-squared Distribution
31. Reading and Writing Data to and from Files
Appending Data to an Existing File
Using read.delim with Non-tab Separator
Choosing a File to Read Interactively
Using Excel for Data Entry
The readxl Function and Tibbles
Reading PDF Files for Data Mining
Writing Graphics Directly to Disc
Appendix 1: Summary of Graphical Parameters
Arguments Passed Directly to par Function
Arguments Applied Directly to the plot Function as well as in Some Others
Arguments for the lines Function
Having Multiple Graphics Windows Open at the Same Time
Macintosh-specific Graphics
Using the layout Function
Using the split.screen Function
Appendix 2: General Housekeeping R Functions and Others Not Covered in the Main Text
General Housekeeping Functions
Setting or Changing the Working Directory
Finding What Files Are in a Directory
Graphical Functions and Parameters
Interaction with User
Mathematical Functions
Writing Concatenated Data Straight to File (in the Working Directory) Using cat
Troubleshooting Package Installation
Appendix 3: Some Useful Statistical and Mathematical Equations
Logical Mathematical Operators
Descriptive Statistics
Distributions
Correlation Coefficients
Statistical Tests
Logarithms and Exponents
Logistic Functions
Weibull and Gompertz Equations
Trigonometric Functions
Convert Radians and Degrees Functions
Bibliography
Web Resources
Index
Cabi
Back
← Prev
Back
Next →
← Prev
Back
Next →