Conflict detection between packets in R

I recently learned that errors can be caused by conflicts between packages, that is, two (or more) packages can have similar functions. I know that the search () code creates a list of packages ordered as R reads them. There is also args code that gives a function read by R.
What would I like to know, firstly, how to determine if an error occurs due to conflicts between packages, and secondly, how to find out which packages contradict each other? Finally, after detecting conflicts, how can we force R to specifically use a function from one of the packages?

+6
source share
3 answers

As @Paul reports, when attaching (for example, via the library function) a package that you can 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 objects are maskedโ€ means that calls to this function will be considered R as function calls in the new package, in my gdata example.

You can avoid this:

 > nobs function (object, ...) UseMethod("nobs") <environment: namespace:gdata> > stats::nobs function (object, ...) UseMethod("nobs") <bytecode: 0x0000000008a92790> <environment: namespace:stats 

hope that helps

+7
source

If R downloads a new package, it will issue a warning if this new package contains any functions that are already present in the production environment. Therefore, if you pay attention while downloading a package, you can see if there are any conflicts. When there are conflicts, you can force R to use a function from a specific package as follows:

 package_name::function_name 
+6
source

I think you're looking for getAnywhere that will tell you all the places where its argument exists. For instance. (in my current load set):

 Rgames> getAnywhere(logit) 2 differing objects matching 'logit' were found in the following places package:boot package:pracma namespace:boot namespace:pracma Use [] to view one of them 
+6
source

All Articles