Creating internal functions (cannot be called from the console) in R

I am working on an R package where I have an overarching function that generates some files, we will call it main(...)and it exists in its own file main.R. Now maincalls other functions, such as helper1(...)and helper2(...), which are in helper1.Rand helper2.R. Is it possible to do this so that it maincan call auxiliary functions, but the user cannot directly call auxiliary functions? I laid them out in different files due to the sharp differences in their purpose. Is the solution to put them under one file main.R?

+4
source share
1 answer

Read the R packages from Hadley Wickham.

that you want ,should be the default for packages: you have exported and not exported functions. If you do not explicitly declare the function as exported, it is invisible to the outside and can only be used for other functions inside the package.

Therefore, you do not need to do anything for helper functions. However, you need to mark the function mainas exported.

+5
source

Source: https://habr.com/ru/post/1626571/


All Articles