Use some documentation tools (md, qmd, or diagram draw.io)
Step 3: packaging
create basic project
Copy and paste exisint R scripts, refactor if necessary (i.e. give self-explanatory names)
Create R generic functions (print, summary)
Document
To do
return result as a list, with class attribute
return argument
Step 4: Qualiy code
It is important to have clean code, so that it is easier to read and maintain; easier to exntend; and the code runs faster.
naming. Make the function and argument names easy to understand
formatting. Indentation, spacing, bracketing should be consistent
simplicity. Avoid unnecesary complexity. Split large source files into smaller chunks, preferably less than 1000 lines.
single responsibility principle (SRP). Each function should have ONE single purpose.
don’t repeat yourself. Make a function!
comment.
error handling. Include error handling messages. tryCatch()
To do
Error handling.
Testing
Why do you need unit tests? In short, increase reliability and maintainability of the code.
Other types of tests exist: integration testing, performance testing, snapshot testing. Package testthat allows not only unit tests, but also the other types of tests.