Paleolimnology and multivariate statistics:
some examples using the R statistical language
May 27, 2011
Many thanks to Pierre Legendre for substantial parts of this page
Last updated: 30 May 2011, 13:10
The workshop will consist in two parts:
- A basic presentation of some methods of multivariate data analysis that are of special interest to ecologists and paleoecologists.
- A practical workshop where participants will be introduced to the basics of the R environment and led through a supervised application of some statistical methods to an example data set.
Installing R on your computer
Participants must install R and several of its additional packages before
Go to the
CRAN web site. You may choose
to go to one of the mirror computers of CRAN.
In the section Download and install R, choose your platform
(Windows, Mac OSX, Linux) and follow the instructions. The current version is R
2.13.0 (but the last number may change).
On MacOS 10.5 and more, download R-2.13.0.pkg. Owners of older
computers (running under MacOS 10.4) may download version R.2.10 by clicking on
the "universal" link of section "Subdirectories", and from there by navigating
to the "base" folder.
Windows users: go to folder "base" of the Windows page, and click on
the "Download R.2.13.0 for Windows" link. While installing R with the
R-2.13.0-win.exe executable, if you want the graphics windows to be independent
of the main R console click « Yes » to Customize the startup
options, then click « SDI (separate windows) » for Display
Apart from the basic R installation, for the workshop you need to install
several additional packages.
Some of them (see list below) are available from the CRAN web site. For
these, choose one of the two methods below:
- Simple, one-step way: make sure that your computer is connected to the Internet, open R and run the following command in the R console:
install.packages(c("ade4", "ape", "cclust", "geoR", "labdsv", "mapdata", "maps", "mvpart", "rgl", "spam", "spdep", "vegan"))
- Using the R menus: Menu "Packages&Data" -> "Package Installer".
Choose a mirror site if requested, then select ade4 in the list.
Before clicking "OK", make sure to check the box "Install Dependencies".
Click OK. Repeat the operation for all other packages.
Three other packages will be needed, but their installation is different. The
the AEM, packfor and PCNM packages must be downloaded from the R-Forge web site. Do not decompress these files; keep them as .zip (Windows) or .tgz (MacOS X). To install these packages into R from your hard disk:
- Windows clients: go to the Packages menu => Install package(s) from local zip files. Navigate to the .zip files and select them one at a time. Always check "Install dependencies".
- MacOS X clients: first you need to install the Fortran compiler to get "packfor" to run. Go to the CRAN Web page, select "MacOS X", then the subdirectory "tools", and finally download the file gfortran-4.2.3.dmg.
Install it on your computer. Then, in the R console, go to the "Package &
Data" menu and click on "Package Installer"; select "Local Source Package"
and click the button "Install". Install the packages one at a time. Always
check "Install dependencies".
- NEW for Mac Users: some of you have encountered problems when installing packfor, PCNM and AEM. I sent an e-mail to all participants with attached compiled versions, but some institutions have rejected the e-mail. So here are the instructions and the zipped folder: 1. Make sure that you have installed the fortran compiler as mentioned above. 2. Unzip the folder, but make sure that within this folder all the files are still in .tgz versions. If your computer has decomprtessed these, retrieve the .tgz versions from the trash bin. 3. In R: Menu "Packages & Data" -> "Source local package" -> click "Install...". Navigate to the folder containing the .tgz files. 4. Select one of the files. The ones most needed are packfor and PCNM. If it still doesn't work and you get the dreaded "Erreur dans getOct(block, 100, 8) : invalid octal digit" message, your computer may lack some XCode tools. In that case, you will have to go to the Mac OS developer's page and down the page, in the section "Developer", click "MacOSX". There you will find a box inviting you to "Download XCode 4". Download it, install it and retry the installation above, starting from step 3. You may have to subscribe to the Mac developer's page, but it is free. Drop me a word if it has worked or not. Please write directly to me, not to the PALS managing team.
R is a self-learning environment. Manuals are available in section
Documentation => Manuals => Contributed documentation of the R web site,
including the guide R for Beginners written by Emmanuel Paradis
(Université Montpellier II). The internal documentation of R is in
R is based on command lines. When working with R, it is best to first write
the commands in a text file and then to transfer them into the R console. I
advise you to install at least one of the text editors suggested below on your
computer if you don't already have one. Complex word processors like MS Word
should be avoided because they introduce lots of hidden control characters which
produce unpredictable results when unwillingly transferred into R. Here are
somme suggestions of free text editors that work well with R:
Introduction and practicals in R by Pierre Legendre and Daniel Borcard
Zipped folder containing a text and R script as well as data files. To make things easy, unzip this folder on your computer and, in R, declare it as your working directory.
Participants, especially those who have no experience in R and/or in
multivariate analysis, are strongly advised to read the introduction and run the
exercises before the workshop.
NEW AND IMPORTANT: new script and data for the workshop
Zipped folder, UPDATED VERSION 26 May 16:45, containing an R script and paleolimnological data. These two files must be unzipped and placed in the same folder as the preceding material. This new script contains the advanced part of the workshop, dealing with two approaches for chronological study of fossil diatom data.
PDF version of the PowerPoint presentation by D. Borcard (1st hour of workshop).
Forward selection of environmental variables
PCNM, MEM and AEM analysis:
To those interested...
New book: Numerical Ecology with R
Main PALS web page