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

Exercise

Documenting function return values

You document the return value of a function using the tag @return. This is where you can tell users what they can expect to get from the function, be that data, a graphic or any other output.

When you write documentation you may want to format the text to look like code, link to other functions or, particularly for return objects, format as a bulleted list. You can do this using special formatting:

  • For code you use \code{text to format}
  • To link to other functions you use \link[packageName]{functionName}, although note the package name is only required if the function is not in your package
  • To include an unordered list you use \itemize{}. Inside the brackets you mark new items with \item followed by the item text.

Instructions

100 XP
  • Document the return value with the following description: "This function returns a data.frame including columns:". Format the word data.frame as code.
  • Add 5 bullets for each of the 5 column names in the order they are returned (the function is loaded if you want to run it).