Exercise

Adding examples

Examples are the way that your end users will learn how to work with your code. You should provide at least one example for any function that is exported. If there are any tricky arguments to your function you might also want to consider examples for those.

Examples should ideally be easily reproducible and should not cause an error. If you are going to publish your package to CRAN then examples should also run in a reasonable time, CRAN sets this to around 15 minutes but it's worth double checking the recommendations at the time of submission.

You add examples using the @examples tag. Examples will typically span multiple lines. This is fine as roxygen will assume that everything is part of the examples until it finds another tag.

Instructions

100 XP
  • Add an examples tag to the data_summary() function header.
  • Add an example of running the function using the iris data.
  • Add a second example of running the function with the airquality data, not removing missing values.