Is there any way to check which packages are actually required by a bunch of source files? The source files were written quite a while ago, and I'd like to remove any packages I have installed that aren't actually required to run certain files.
rsconnect package has appDependencies function.
Take a look at that and its accompanying help page.
Does that only work for projects/packages? Mine are just a collection of source files without
:: operators, it just functions on the basis that those packages are already installed
the documentation says
This function parses all .R files in the application directory to determine what packages the application depends on; and for each of those packages what other packages they depend on.
Dependencies are determined by parsing application source code and looking for calls to library, require, ::, and :::.
if you are looking at code that assumes libraries are attached and never mentions their name spaces, then I think you will be out of luck from automated tools.
Yeah, unfortunately the code has a line at the beginning that installs and attaches libraries of a load of packages even though a lot of them aren't actually required.. I was hoping there might be a function that can inspect the actual functions called and compile a list of packages required from that but it doesn't seem likely. Thanks anyway!
you could maybe adapt this approach to find the functions.
Then you would have a seperate challenge to look up the functions against the possible packages that they might have come from
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.