statquant statquant - 2 months ago 6
R Question

How can I find where the package I loaded comes from

I want to programatically save some packages my script has loaded (I mean the actual directory).

I know doing

.libPaths()
shows the paths where the packages can come from (though I could also load it from somewhere different).

Is there an already build function to get where a package that I loaded comes from ?

J_F J_F
Answer

My solution would be:

sess.info <- sessionInfo()

names.packages <- names(sess.info$loadedOnly)

find.package(names.packages)

I hope this is what you are searching for.