1. Learn
  2. /
  3. Courses
  4. /
  5. Developing R Packages

Connected

Exercise

Function returns and exporting

When documenting the return value of a function, you specify what users can expect as the output of the function, whether it's data, a number, a vector of strings, or any other R result.

While the NAMESPACE file is responsible for identifying exported functions, you create this file using roxygen2 tags. By using these tags, you can easily determine whether users will have access to a function right alongside its documentation. You mark a function for exporting in the roxygen2 header. This straightforward approach ensures that you can clearly indicate which functions are available for users to work with in the documentation itself.

Instructions

100 XP
  • Document the return value with the following description: "A numeric distance value in the unit specified as `unit_to`."
  • Export the function.