burglr
burglr copied to clipboard
Error if a variable is named `x`
Hi Antoine,
Thanks again for this very nice package.
There is a small but very surprising bug that occurs when a variable x
is already declared in the global environment and you want to burgle a function that has an x
argument itself. Removing this variable saves the day.
Here is a reprex:
> x=1
> burglr::burgle(base::mean)
Copying base:::mean and its dependencies
base is licensed: Part of R 4.1.0
and is by:
R Core Team and contributors worldwide
base:::mean
base:::mean.Date
Error in burgle1(nm, pkg, export = TRUE, first = FALSE) :
can't make sense of environment of `x`
In addition: Warning message:
In stop(e, call. = FALSE) : additional arguments ignored in stop()
> burglr::burgle(scales:::alpha)
Copying scales:::alpha and its dependencies
scales is licensed: MIT + file LICENSE
and is by:
Hadley Wickham [aut, cre],
Dana Seidel [aut],
RStudio [cph]
Remember to comply with the terms of the license of the code you are using.
See https://r-pkgs.org/license.html for more info.
> rm(x)
> burglr::burgle(base::mean)
Copying base:::mean and its dependencies
base is licensed: Part of R 4.1.0
and is by:
R Core Team and contributors worldwide
base:::mean
base:::mean.Date
base:::mean.default
base:::mean.difftime
base:::mean.POSIXct
base:::mean.POSIXlt
Remember to comply with the terms of the license of the code you are using.
See https://r-pkgs.org/license.html for more info.
Thanks Dan, I'm not actively working on this package and will work first on the licensing aspects when I do, but hopefully I will get there!
I think I remember that {burglr} cannot be 100% robust and must use heuristics that work most of the time, so maybe it's such corner case, the error seems to indicate so. On the other hand rarely, and probably never with good practice, will a package refer to a variable in the global environment so probably I can work around this specific case.