Chapter 5 Functions
You’ll need to organize your code into functions in order to use the code in a package.
Function structure:
You can call the function
#> [1] 25
5.1 Exercise
Write your own function
- Write a function
- Run it!
- Any problems? report back
5.2 Functions in a package
In a real R package you DO NOT want to export all functions in the package.
RStudio/devtools
/usethis
/etc. do put
exportPattern("^[^\\.]")
in your NAMESPACE
file by default.
Important: Make sure to remove this and explicitly export functions that you want
users to use with RStudio buttons or devtools::document()
or similar.