Skip to content

Commit

Permalink
Merge pull request #1053 from ethanwhite/r-intro-update
Browse files Browse the repository at this point in the history
Add challenge exercise for vectors
  • Loading branch information
ethanwhite authored Aug 25, 2024
2 parents cc8afef + 2a515ba commit 470ff83
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assignments/r-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layout: page
element: assignment
title: Introduction to R and RStudio
language: R
exercises: ['Basic Expressions', 'Basic Variables', 'More Variables', 'Built-in Functions', 'Modify the Code', 'Basic Vectors', 'Nulls in Vectors', 'Shrub Volume Vectors', 'Check That Your Code Runs', 'Variable Names']
points: [10, 10, 10, 10, 10, 10, 15, 15, 10, optional]
exercises: ['Basic Expressions', 'Basic Variables', 'More Variables', 'Built-in Functions', 'Modify the Code', 'Basic Vectors', 'Nulls in Vectors', 'Shrub Volume Vectors', 'Check That Your Code Runs', 'Biomass vectors']
points: [10, 10, 10, 10, 10, 10, 15, 15, 10, Challenge - optional]
---

### Learning Objectives
Expand Down
31 changes: 31 additions & 0 deletions exercises/Vectors-biomass-vectors-R.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: exercise
topic: Vectors
title: Biomass vectors
language: R
---

You have data on the diameter of all of the trees in three sites and each site includes a mix of managmeent stratagies.
Tree masses can be estimated using diameter based on the equation `mass = 0.124 * diameter ^ 2.53`.
The biomass is the sum of the masses of all the trees at a site.
Copy the vectors below into your R script.


```r
site <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3)
diameter <- c(10.5, 14.2, 13.7, 15.3, 12.8, 9.8, 11.4, 10.9,
12.1, 13.5, 14.7, 8.5, 9.2, 10.1, 11.3, 12.4,
13.6, 14.8)
management <- c("active", "active", "passive", "passive",
"active", "passive", "active", "active",
"passive", "passive", "active", "active",
"passive", "active", "passive", "active",
"passive", "active")
```

*Using only the tools we covered in class* and the information above, answer the following questions:

1. What is the mass of the largest tree, which site is it in, and what is its management status?
2. Which site has the greatest total biomass and what is that biomass?
3. What is the average mass of a tree in each site?
4. What is the difference in total biomass for each site between the "active" management and "passive" management strategies?
1 change: 1 addition & 0 deletions materials/r-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ weight_g

### Assignments format

* **SEPARATE FILES FOR CLASS CODE ALONG AND HOMEWORK**
* Comment before each problem and each sub-problem
* Make sure result prints out on `Source with echo`

Expand Down

0 comments on commit 470ff83

Please sign in to comment.