shrtcts
shrtcts copied to clipboard
Locally defined functions not found
Many of my shortcuts have a nearly identical structure and share large parts of their code. In order to reduce duplication I would like to extract shared code into helper functions which are not shortcuts themselves, e.g.
# .shrtcts.R
# helper function reused across the file
print_message <- function(message) {
cat(message)
}
#' Print message 'foo'
#'
#' @description
#' Print 'foo'
#' @interactive
print_foo <- function() {
print_message("foo")
}
#' Print message 'bar'
#'
#' @description
#' Print 'bar'
#' @interactive
print_bar <- function() {
print_message("bar")
}
Executing print_foo
, this approach leads to the error message Error in print_message("foo") : could not find function "print_message"
.
Is there a way to modularize the code for shortcuts? I could not find any remarks about this in the documentation.
Thank you very much for this great package!