In general, I feel the nordcan.R script has become a bit long and contains
many lines of code that the user does not need to see with their own eyes.
For instance, how the object "._undefined" is handled could be done by writing
one or two functions into on of the nordcan R packages and calling them,
instead of writing all the code into nordcan.R. Actually "._undefined" should
not be done in this way (I wrote that originally). I would now save it into an
environment object in one of the nordcan R packages (similarly to how the
NORDCAN global settings are currently saved). Then it can be accessed by calling
some function written into one of the NORDCAN packages if needed. Something
like this:
if (has_problem) {
warning("there were bad icd10 codes, use nordcanpkg::undefined_icd10_get",
"or nordcanpkg::undefined_icd10_csv to see them.")
undefined_icd10_set(undefined_icd10_code_dt)
}
I don't think the script is so long that we HAVE to shorten it, and sometimes it is also valuable for the user to see some of the commands, but I agree that we should look through it and see if there are some places we can shorten down by using functions.
I suggest you look through the script to see if there are places like Joonas mentions above which is script on "pure data handling" that the users are not that interested in and see if you can hide those by using functions. Script which gives valuable information on what is happening to the cancer data might be valuable to keep more visible.
A new version of "nordcan.R" is shortened by wrapping some codes which are not necessarily exposed to users. The updated version is more concise and easy to understand the purpose of each step.
Joonas writes:
in function which needs it...
if (has_problem) { warning("there were bad icd10 codes, use nordcanpkg::undefined_icd10_get", "or nordcanpkg::undefined_icd10_csv to see them.") undefined_icd10_set(undefined_icd10_code_dt) }