Is it good to include every library that I need to execute a function inside this function?
For example, my file global.rcontains several functions that I need for a brilliant application. Currently, I have all the necessary packages at the top of the file. When I switch projects / copying these functions, I have to download packages / include them in new code. Otherwise, all necessary packages are contained in this function. Of course, I need to test all the features with a new R session, but I think this can help in the long run.
When I tried to download the package twice, it will not download the package again, but checks that it is already downloaded. My main question is: can it slow down my functions if I restructure this way?
I saw this practice only once, the library calls inside the function, so I'm not sure.
source
share