Homework

Homework for R data analysis and visualization workshop

This workshop will begin with R concepts related to analyzing and visualizing your data in R for scientific communication and publication. As a result, we will not be covering the basics of coding in R. If you need a reminder of coding in R for ecologists, please work through the online tutorial found here (all episodes in the left-hand table of contents are required) before the MITSI retreat. Whether you need the refresher or not, all participants are expected to complete homework steps 1-5 outlined below and acknowledge your completion and answers in the pre-workshop survey google form by Thursday, August 10.

Before the workshop, please make sure you have completed the following homework steps:

1. Download/Update R and RStudio

You will need a current version of R and RStudio for this workshop. You can find instructions for installing or updating these programs here.

Follow the instructions under the Install R and RStudio or Update R and RStudio sections to ensure you have these programs on your computer.

2. Create an R Project for your research project and organize your files

Follow the instructions here to create an R Project within a folder (directory) on your computer that will house all of your data, code, and documents for your research project. I use a Mac and here is a screenshot of a finder window with an example folder structure that works well for most projects. You should have something that looks like this:

3. Have your data in a tidy format (bonus challenge to get data tidy in R!)

Your data need to be in tidy format before you can analyze and visualize them. You can revisit concepts of tidy data in this online tutorial. In general, “tidy” data needs to have one row for each observation and column names should have computer-readable titles. If your dataset has many variables, data tidied for analyses may only need to include a relevant subset of them. If you can easily plot one variable in your dataset against another one (in R or Excel), then those data are “tidy”. Common reasons data might not be “tidy” that could relate to your data:

  • metadata in top rows of a dataset (Fix: “Filter” rows based on criteria or row order)

  • there are more columns than you need in your dataset (Fix: “Select” columns based on their names)

  • column names aren’t computer-readable (Fix: “Rename” columns to be computer-readable)

  • multiple individuals (e.g., plants, branches, cones) are collected per a site or individual and each is its own column (Fix: “Reshape” data so that each column becomes its own row)

I’ve provided links for each of these common issues on how to perform these tasks in R. In general, creating reproducible ways to get from your “raw” data to any “cleaned” data is best practice, but do these tasks however you feel comfortable performing them (e.g., in Excel or other spreadsheet software). NO MATTER WHAT: Always save your original data collected in a “raw” file that you NEVER alter. Any changes you make either in R or other programs to “clean” and “tidy” your data should be saved as new documents. This is why the file organization I suggested has a subfolder for “raw” and “clean” data.

4. What are 2-3 questions you want to ask of your data?

Scientific discovery is built on asking questions about patterns in observational and experimental data. These questions inform which statistical tests you perform on your data as well! Sound scientific questions often take the form of “what is the effect of x on y?”. In this case, “x” is an “independent” or “predictor” variable (e.g., it’s the variable that is shaping the variable “y”). Then, “y” is the “dependent” or “response” variable, or the variable that is potentially being shaped by changes in your “x” variable. Some example scientific questions include, “What is the effect of climate (precipitation and temperature) on plant growth?”, “What is the effect of nutrient and water addition on soil respiration?”, “What is the effect of extreme drought on bird egg survival?”, “What is the effect of invasive species presence on seed germination?”.

In the workshop, we’ll dive deeper into the types of data we have in ecology, but before the workshop, all you need to do is write down 2-3 questions in the structure described here about your data.

5. What are 2+ figures you would like to create with your data?

There are many ways that we can visualize ecological data. Generally, we do data visualization both as a data exploration step and as a visual aid in sharing out results of our analyses. In the workshop we’ll talk about best practices for data visualization, but it is good for you to have some thoughts on how you would like to visualize your data before the workshop. Here’s a great gallery of many of the ways that data can be visualized.

Before the workshop, think of 2 or more figures you would like to create to visualize your data. These could be exploratory or more polished “results” figures. Write down a general description of these figures such as “a line graph of soil respiration through time by treatment” or “a boxplot of seedling counts by treatment”. It’s okay if these are vague, we’ll spend time on this in the workshop!

Recap: Pre-workshop homework requirement

Please complete steps 1-5 above and include your answers in the pre-workshop survey Google form by Thursday, August 10.