Reputation: 28022
Suppose there is a method (let's say "sample ()") and that it is present in multiple packages (let's say both in package "base" and "arules"). Now if I call sample () which package is called, does it call the package "base" or "arules" and how does it decide which one to call?
Upvotes: 2
Views: 79
Reputation: 66834
It selects which one comes first on the search
path:
search()
[1] ".GlobalEnv" "package:arules" "package:Matrix"
[4] "package:stats" "package:graphics" "package:grDevices"
[7] "package:utils" "package:datasets" "package:methods"
[10] "Autoloads" "package:base"
So it would be the arules version. This is an S4 method which actually may call the base version anyway. Note that base is always last on the search path, and the global environment is always first. Generally packages are loaded in second place (can be changed with the pos
argument to library
), and moved down as others are loaded.
Upvotes: 8