Exercise

Best practice for structuring code

A typical R package contains a number of functions that you need to maintain. Whilst there are no strict rules around how you should structure code in a package you generally want to avoid having all of your code in a single script. As you can't have sub-directories you also need to think carefully about how you name the file so that you can find your code again in the future.

Suppose you were to write another function for your package that takes all numeric columns in your data and returns a data frame of all of their summary statistics. What would be the best way to structure this code?

Instructions

100 XP
  • Send the new data_summary() function to a new file taking the same name as the function (You should use the dump() function here).