A tutorial for writing functions in R (CC177)
Channel: Riffomonas Project
Date: 2022-01-10

Writing your own R functions is critical to expanding the versatility and reproducibility of your code. In this epsiode Pat shares almost everything you'd ever want to know about writing your own R functions and then applies this knowledge to adapt the code he's been writing in this series into a function. This is part of a series of videos demonstrating how to functions from base R to make these data compatible with tools from the tidyverse

You can find my blog post for this episode at https://www.riffomonas.org/code_club/2022-01-10-functions.

The data were generated in our Kozich et al. 2013 paper (http://doi.org/10.1128/AEM.01043-13) using samples from the Schloss et al. 2012 paper (http://doi.org/10.4161/gmic.21008).

#attr #Rstats #baseR #str

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/

You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Creating your own functions in R
1:52 Syntax for writing a simple function
3:28 How to use your custom functions
6:12 Assigning default values to arguments
6:50 Creating more complex functions
8:17 Determining what gets returned from a function
9:56 Converting our code into a function