After I install the config package, I can no longer use merge function on my dataframes. I am getting error message "merge in error, ..., unused arguments."
Asked
Active
Viewed 198 times
2 Answers
1
Looks like config
has a merge()
function which overrides the base
function.
Type base::merge()
to get the base R function.
EDIT: or as pointed out by @PoGibas, don't load config
and use config::merge
.

neilfws
- 32,751
- 5
- 50
- 63
-
I have a lot of codes using the merge function, is there a way to fix this without adding base:: to every call? Thanks. – John Smith Mar 08 '18 at 02:20
-
1@JohnSmith you can use `config` package functions with `config::function` instead of loading it. Might be more logical than overwriting `base` `R` functions. – pogibas Mar 08 '18 at 02:44
-
2@JohnSmith btw even in their [vignette](https://cran.r-project.org/web/packages/config/vignettes/introduction.html) code they don't load the package and use it with `config::package` – pogibas Mar 08 '18 at 02:47
0
Another way to address the problem of config
masking base::merge()
is to load the config
package, use it to configure the environment, and then use detach()
to remove the package. This will unmask base::merge()
.
library(config)
# use config functions to set up environment
#
At this point we can show that config::merge
is the default by printing the merge()
function.
> merge
function (base_config, merge_config)
{
merge_lists(base_config, merge_config, recursive = TRUE)
}
<bytecode: 0x7fcddf5de488>
<environment: namespace:config>
>
To restore base::merge()
as the default, we use the detach()
function.
detach(package:config)
# at this point base::merge() and base::get() are unmasked
To demonstrate this, we'll print the merge()
function again.
> detach(package:config)
> # print merge function to show it is from base package
> merge
function (x, y, ...)
UseMethod("merge")
<bytecode: 0x7fcde7c08e70>
<environment: namespace:base>
>

Len Greski
- 10,505
- 2
- 22
- 33