FES 720 Introduction to R

LAB: Logic

This is the lab associated with the lesson on Lists in R.

Please upload your final completed lab on the Assignments page in Canvas, as per the instructions below.

You are welcome and expected to ask for help from the instructors if you get stuck: Please also come to the R Bootcamp on Friday—there is coffee and snacks!


A. Michigan Tree Plot data

# Read in the data
dat_tree <- read.table("http://www.simonqueenborough.info/R/data/treespecies_cleandata.txt", 
                       header = TRUE, sep = '\t')
  1. Use the function which() to return which rows of the data pertain to Black Oak.

  2. Use this expression to subset out the rows of data for Black Oak.

  3. Use length() to return the number of trees of Black Oak.

  4. Compare this number to the number of Hickory trees. Are there more Hickory than Black Oak?

  5. Use which() to subset out the rows of data for all the Oak species.

  6. Are there more Oak trees than all of the other species?

B. New Haven 5K Race data

# Read in NHV road race results 2015.
dat_nhv <- read.table("http://www.simonqueenborough.info/R/data/race-data-full.txt", sep = '\t', header = TRUE)
  1. Use a logical statement to count how many runners were not from New Haven.

  2. How many people ran faster or equal to 20 minutes (dat_nhv$Nettime_mins)?

  3. How many people ran faster than 20 minutes AND were from New Haven?

  4. How many people ran faster than 20 minutes AND were from New Haven, Branford, Guilford, or Madison?


How to write up your answers

Please check the help page for a reminder, if you need to.


Updated: 2017-10-15