which library is prioritized?

packagemanagement

#1

Hello there,

I am afraid this is a noob question, but I realize I have the same package installed in my user library and in my system library. In this case, who wins when calling library(thispackage) in my scripts? Can there be conflicts?

Thanks!


#2

I was somehow certain that it'll prioritize first package library sees in .libPaths(), but reading actual code it looks like your case will be handled by this:

        if (length(paths) > 1L) {
            if (verbose) 
                warning(gettextf("package %s found more than once, using the first from\n  %s", 
                  sQuote(pkg), paste(dQuote(paths), collapse = ",\n  ")), 
                  domain = NA)
            paths <- paths[1L]
        }

However, there is nothing specific mentioned in helpfile for library(), so maybe it's handled differently (code is a bit hard to parse just by looking at it).

So, my suggestion would be to try :slight_smile: . I'm now curious whether you'll get the warning above.


#3

perhaps the safest thing is to say, just use my user library? Do you know how can I do that?


#4

Yes, library has lib.loc parameter specifically for that. You can pass it a character vector with location where you want library to look.