5 Part II: Tree Sapling Study
In this section we will be working with the SaplingStudy dataset. We are giving you less code here; but many of the tasks are similar to what you just completed in Part One. Your task is to adapt the code given above to these new datasets and questions.
Dataset Overview: A team of researchers at MUN went to each ecoregion and sampled all the different tree saplings that grew that year. The goal of this study was to see if moose have browsing preference on sapling species. For each tree they recorded
The height of the tree (cm)
The moose browsing intensity: With 0 being no browsing by moose and 5 meaning severe browsing.
Step 1
a. Load the data file: SaplingStudy.csv and save your dataset to a name (e.g., Saplings).
- Then remove the
NAs from the dataset usingna.omit()function. Remember to save the cleaned version of your dataset to a new name (or override the old name).
Step 2
With the help of pipes %>%, create a new database using the group_by() function to group the data by Ecoregion, and then use summarize() to calculate the mean() moose BrowsingScore for each site. Print the result using the print() function.
HAND-IN Question 4
How does moose browsing pressure vary across different ecoregions? Which ecoregion has the most moose browsing. Which ecoregion has the lowest?
Step 3
With the help of pipes %>%, use the group_by function to group the data by Ecoregion, and then use summarize() to calculate the mean() tree Height for each group. Print the result using the print() function. HINT: Adapt the code from Step 2 above.
HAND-IN Question 5
How does the average tree height vary across different ecoregions? The team considered average heights less than 20 cm to be severely browsed by moose. Which ecoregions have average heights less than 20 cm. HINT Do this by looking at your data or using a filter(). Print the result using the print() function.
Step 4
Use the group_by function to group the data by Species, and then use summarize() tocalculate the mean tree BrowsingScore for each group. Print the result using the print() function. HINT: Adapt the code from Part II, Step 2.
HAND-IN Question 6
How does the average browsing score vary across different tree sapling species? Which species has the highest browsing score, which species has the lowest?
Step 5
A team of researchers in interested in how Balsam Fir browsing intensity varies by ecoregion. With the help of pipes %>%, use the filter() function to filter the Species column for only Balsam_Fir, then use group_by() function to sort by Ecoregion , and then determine mean() moose BrowsingScore. Remember to save the resulting summary table under a new name (E.g.,BalsamFir). HINT: Adapt the code from Step 2 above.
Step 6
Using the BalsamFir dataset you created in Step 5, make a bar graph the barplot() function. Each bar should represent an ecoregion, and the height of the bar should reflect the average browsing intensity.
Follow the template below and replace the placeholder names with the appropriate column names from your dataset:
barplot(Dataset$YAxisColumn, names.arg = Dataset$XAxisColumn, xlab = "X-axis name goes here", ylab = "Y-axis name goes here", main = "Figure title goes here", col = "forestgreen", #pick any colour you want cex.names = 0.6) # Reduces x-axis label size for readability
Step 7
We are going to now look at how Black Spruce browsing intensity varies by ecoregion? Repeat the steps from Step 5 and 6 above but now with Black Spruce.
HINTS
a) With the help of pipes, use the filter() function to filter the Species column for only Black_Spruce, then use group_by() function to sort by Ecoregion , and then determine mean() moose BrowsingScore. Remember to save the resulting summary table under a new name (e.g., BlackSpruce).
- Using the dataset you just created, make a bar graph the
barplot()function to show the Average browsing score for Black Spruce across the ecoregions. Each bar should represent an ecoregion, and the height of the bar should reflect the average browsing intensity
HAND-IN Question 7
How does Black Spruce browsing compare to Balsam Fir browsing across ecoregions? Export the two bar graphs you just created into your Word document to provide evidence to illustrate your answer.
Step 8
Add a line of code where you use the group_by() function and the tally() function to determine how many trees were counted in each Ecoregion?
Step 9
Were the same number of tree saplings counted for each species? Add a line of code where you use the tally() function to determine how many individual trees were counted in for each Species? HINT: Adapt the code from Step 8 above.
HAND-IN Question 8
Were the same number of tree saplings counted in each Ecoregion?
HAND-IN Question 9
In any ecological study, it’s important to ask whether the dataset accurately reflects the system you’re trying to understand. IEvaluate whether sampling bias may be affecting your interpretation of moose browsing patterns. Do you think the SaplingStudy dataset is evenly distributed? Are any ecoregion(s) or tree species overrepresented, are any underepresented in the dataset? Why is it important to recognize bias in ecological datasets?