Detect conflicts between packages in R
conflict, package, r
Solution
As @Paul says, when attaching (e.g. via `library` function) a package you may get:
> library("gdata", lib.loc="C:/Program Files/R/R-2.15.3/library")
gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
Attaching package: ‘gdata’
The following object(s) are masked from ‘package:stats’:
nobs
The following object(s) are masked from ‘package:utils’:
object.size
When you get "The following object(s) are masked" mean that calls to those function will be thought by R as calls to the functions in the new package, in my example `gdata`.
You can avoid this via:
> nobs
function (object, ...)
UseMethod("nobs")
<environment: namespace:gdata>
> stats::nobs
function (object, ...)
UseMethod("nobs")
<bytecode: 0x0000000008a92790>
<environment: namespace:stats
hope that helps
Problem
I've recently found out that errors can be caused due to conflicts between packages, that is, two (or more) packages might have functions named similarly. I know that the code `search ()` produces the list of packages ordered in the way R reads them. There is also the `args` code which gives the function read by R. What I would like to know firstly is how to detect if an error is being produced because of conflicts between packages and secondly how to find out which packages are conflicting? Finally, after the conflicts have been detected, how can we force R to use specifically the function from one of the packages?