This website contains the lab exercises for the MSU Graduate course: Spatial Ecology (IBIO870; cross-listed FW/FOR), Fall 2022. Labs will be posted through the semester. The labs are generally mixtures of background, code with descriptive text, and results. Most labs have exercises for you to produce working code and output such as plots, and will require R and RStudio. Please read the instructions under “LAB” on D2L, and on the Syllabus. These contain due dates, how to submit your Lab assignments, and expectations. If you are coming to this website and are not enrolled in the course, feel free to try out the exercises.

Please note that this website is Version 1.1, and includes labs recently updated from previous semesters of Spatial Ecology. Please let me know if anything is unclear.


  • Install R and and the “Open Source Edition” of Rstudio desktop (both free) on your computer. For more information on installing those programs, see D2L: R in Resources, https://datacarpentry.org/R-ecology-lesson/index.html, or our the MSU SpaCE Lab’s guide here: https://space-lab-msu.github.io/r_guide/installing-r-and-rstudio.html
    Note you may safely use all the defaults options during these installations.

  • It will be helpful to replicate the folder (directory) structure for Labs on your computer as follows:

  • Create a folder for this course (something like ‘SpatialEcologyLab’). This is your working directory.

  • In your course folder, create a ‘data’ folder that will be used by some labs. Within this folder, add folders (subdirectories) for each lab in all lowercase, before starting a lab. For example, create ‘lab1’ before you work on lab1.

  • Place the .R or .Rmd files for each lab in your working directory and work from that directory.

General Instructions

The labs provide example, working code that you can use to complete the exercises. You may copy/paste this code into your own scripts. Or start from the source code (see R Markdown below)

Most labs use data pulled from the internet, and usually with R code to do that downloading automatically. In the event that you cannot download these data from the internet, they are also linked on this page, or in the Lab text itself.

R Markdown

Lab 2 describes how to write code so that you can create a report in a format called “Markdown”, or a format specific to R called “RMarkdown.” For all Lab assignments starting with Lab 2, you will write RMarkdown files that you’ll use RStudio to run and create a PDF. The PDF includes your write-up, your code, and the outputs from your code (text, plots, images, etc). You turn in this PDF for credit.

The lab documents themselves were written in RMarkdown, and used R to run all the code, create the plots, and then create this website to make it easy to read. To help you get started on your exercise, you can also download these RMarkdown scripts and run them on your own computer to see how they work, or to use them to start working on your Lab assignment.

Each lab will have a link at the top to the “source code” for the lab (in “RMarkdown format” or Rmd). Lab 2 contains more information about RMarkdown and how to use it.


A few labs need other files to be complete, and if these are necessary they will also have links to them. However all the data used by all of the labs is available in the “data” folder on https://github.com/SpaCE-Lab-MSU/MSUGradSpatialEcology/tree/master/docs


I don’t expect you to be familiar with git or GitHub (which you may have heard of) but this is a convenient way to make all of the R source code and data files available to you. We will go over an introduction to GitHub in a future Lab.

Lab Community Forum

Please see the Syllabus and D2L for a full description of the Lab Community Forum. The Lab Community Forum is a collection of Google Docs in the course Google Shared Drive, one for each Lab. Further instructions are found at the top of each Lab Community Forum Google Doc. Remember that even if you don’t have a question to post to the Lab Community Forum, you can add in some helpful tips you came across while using R that relate to the Lab. Participation in this course includes contributions to this Forum. See D2L “LABS” for the link.

Creative Commons License
This work is licensed under a Licensed under CC-BY 4.0 2020; 2022 by Phoebe Zarnetske.