I am creating an R package and would like to organize an R subdirectory with subdirectories. Since only the function defined in the R files in the root directory is exported, I added this code to a single file in the root directory:
sourceDir <- function(path, trace = TRUE, ...) { for (nm in list.files(path, pattern = "\\.[RrSsQq]$")) { print(nm) if(trace) cat(nm,":") source(file.path(path, nm), ...) if(trace) cat("\n") } } sourceDir("R/DataGenerator")
When I use "CRTL + SHIFT + B" on RStudio, I see that nm files are received. But once the package is loaded, none of the functions defined in the R / DataGenerator subdirectory are available without using :: or using :.
How can I export functions defined in R subdirectories? Is it possible?
source share