###################################################################
############### Module 6, Basics of data wrangling ################
###################################################################
### EXCERCISES (Lessons 10 and 11):

# 1) Load the package "tidyverse"


# 2) Upload the dataset named "mammal_exc_vegetation.csv" directly into a tibble dataframe


# These data are based on a large scale large mammal exclosure experiment in an African savanna.
# The data we have here are based on vegetation surveys of all plant understory species
# present in m^2 subplots in a 7x7 grid in each plot.
# SURVEY = survey number/census
# YEAR, MONTH, DATE = the date surveyed
# SITE = the plot location (North (dry), Central (intermediate), South (wet))
# BLOCK = each site has three blocks (1-3)
# TREATMENT = OPEN = open plots (no exclosure)
#             MEGA = mega-herbivores excluded
#             MESO = meso- and mega-herbivores excluded
#             TOTAL = all herbivores excluded;
#             OUT = near to, but outside experimental plots (rarely used).
# PLOT = unique plot identifier combining SITE, BLOCK, and TREATMENT
# COORDINATE = indentifier for each m^2 subplot 

# More info and descriptions here:
# http://www.esapubs.org/archive/ecol/E095/064/#data
# Based on this citation:
# # Tyler R. Kartzinel, Jacob R. Goheen, Grace K. Charles, Elyse DeFranco, Janet E. Maclean, 
# Tobias O. Otieno, Todd M. Palmer, and Robert M. Pringle. 2014. Plant and small-mammal 
# responses to large-herbivore exclusion in an African savanna: five years of the UHURU
# experiment. Ecology 95:787.


# 3) Remove the columns of SURVEY, and YEAR and rename the non-species columns into a lower-case
# format and rename COORDINATE to something more meaningful (e.g., subplot)


# 4) Filter the data to only OPEN and TOTAL treatments:


# 5) Create a subset of the data that includes only species of the genus "Eragrostis." 
# Hint: you may need to use a more basic indexing method with the grepl function:


# 6) Use the pipe "%>%" operator to combine your answers to questions 3, 4, and 5 into one
# script that selects/renames columns and filters the dataframe.


# 7) Convert the Eragrostis species columns to either 0s or 1s indicating absence or presence. Remember
# that a "B" value indicates the species is present in a plot. Hint: you will need to use the mutate function.


# 8) Use the split-apply-combine procedure to calculate the total number of Eragrostis_tenuifolia found
# within each site and treatment. Use the tibble from the previous question.


# Great work!
