Skip to content

Update funandloops.md #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions _tutorials/funandloops.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ diam.summ <- function(dbh, mean = TRUE, median = TRUE, ba = TRUE){
return(as.data.frame(na.omit(t(data.frame(mean_dbh, median_dbh, mean_ba)))))
}

diam.summ(dbh = bicuar_trees$diam, mean = TRUE, median = FALSE)
diam.summ(dbh = trees_bicuar$diam, mean = TRUE, median = FALSE)
```

Also note that in this function definition the extra arguments have default values, e.g. `mean = TRUE`. This means that even if the user doesn't specify what the value of `mean` should be, e.g. `diam.summ(dbh = trees_bicuar$diam, median = TRUE, mean_ba = FALSE)`, R will default to the value of `mean = TRUE`, thus calculating the mean trunk diameter.
Expand All @@ -319,9 +319,11 @@ Also note that in this function definition the extra arguments have default valu

This final section for the workshop provides another real world example using simple `for()` loops and functions to create multiple graphs of population trends from the [Living Planet Index](http://www.livingplanetindex.org/) for a number of vertebrate species from 1970 to 2014. Work through the example to make sure that all the code makes sense, remembering the lessons from earlier in the workshop.

First, import the data:
First, load required packages and import the data:

```r
library(dplyr)
library (ggplot2)
LPI <- read.csv("LPI_data_loops.csv")
```

Expand Down