-
Notifications
You must be signed in to change notification settings - Fork 31
Coding principles
We wish the package to be easily used and integrated into then normal analysis and visualisation flow. This requires maximal compatibility with existing standard tools and packages. All new functions should thus preferably be built using the widely adapted tidyverse.
- Data is expected to be present in tidy form (one row per observation) unless otherwise noted.
- Ideally tibbles are used rather than dataframes.
- The magrittr pipe (
%>%
) should be used for consecutive operations on the the data. - For models the broom package easily converts key information about the models into tidy data tibbles for subsequent wrangling and visualisation.
- Plotting should be implemented using ggplot2 unless this is not possible.
- Interactivity may be provided using ggplotly or - if needed plotly or other packages
- CRAN requires us to use TRUE/FALSE, so don't use T/F.
- Tables should always be also available as raw tibbles and output should not be only in formatted ways (e.g., only html, only markdown etc.)
- Write tests as soon as the function is in a somewhat usable state. Improving is easier than starting.
- Use vdiffr for comparison of anything plotted against a library of manually curated plots.
- Educate over break: Rather than just stopping if parameters have been provided that don't make sense, like
shape = NULL
, just warn the user that this doesn't make sense and set it to a reasonable default, the function's default if applicable.- "But what if the user wanted to disable the
shape
that way?" -> Then just don't call the function to add it.
- "But what if the user wanted to disable the
We have integrated several "watchdogs" into our testing routine to ensure adherence to certain standards that we've set. Those routines scan our codebase for possible style violations, similar to a linter, and update certain details.
For a successful submission to CRAN, certain rules have been set in place by the CRAN team, as for example the usage of TRUE
/FALSE
over T
/F
. To continuously ensure compliance with those, our CRAN watchdog scans the respective files for violations of those.
We want to make it easy to use our package in a more stringent environment that might require all packages to be validated. Based on discussions and similar projects we decided to implement traceability into our testing files. Therefore, both the tests as well as the last change to those, are automatically written into the files for potential scraping. The details on the last change are gathered by usage of git log
and then table of contents for the unit test specifications are generated based off of the strings in the actual tests.