I have a very long R script with many if statements and exception cases. As i\'ve been going, if been importing and testing libraries as I\'ve gone and haven\'t really docum
I am not sure of a good way to automatize this... but what you could do is:
Check with sessionInfo that you don't have extra packages loaded.
You could check this using sessionInfo. If you, by default, load extra packages (e.g. using your .RProfile file) I suggest you avoid doing that, as it's a recipe for disaster.
Normally you should only have the base packages loaded: stats, graphics, grDevices, utils, datasets, methods, and base.
You can unload any extra libraries using:
detach("package:", unload=TRUE)
Now run the script after commenting all of the library and require calls and see which functions give an error.
To get which package is required by each function type in the console:
??
Load the required packages and re-run steps 3-5 until satisfied.