-
Notifications
You must be signed in to change notification settings - Fork 125
Description
I sometimes want to use only the tmap::qtm()
function without loading the entire tmap
package. However, when doing so, I encounter the following error due to internal functions like tm_const()
not being explicitly specified:
# install.packages("sf")
# install.packages("tmap")
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) |>
sf::st_transform("EPSG:3857")
tmap::qtm(nc, fill = "BIR79")
#> Error in tm_const(): could not find function "tm_const"
Created on 2025-03-14 with reprex v2.1.1
It seems that this issue arises because the internal function calls (e.g., tm_const()
) are not explicitly qualified with the package name (i.e., tmap::tm_const()
). The function is currently defined as:
qtm = function(shp = NULL,
fill = tm_const(),
col = tm_const(),
size = tm_const(),
...) { ... }
Instead, it would need to be written like this:
qtm = function(shp = NULL,
fill = tmap::tm_const(),
col = tmap::tm_const(),
size = tmap::tm_const(),
...) { ... }
Questions:
- Is it desirable to make all internal function calls explicit in this way?
- I wonder if there are any potential issues or trade-offs I might be overlooking.
- Would making internal functions explicit cause any issues, such as affecting package checks or compatibility?
I tried using {pedant}
to automatically qualify functions, but it only works with functions listed in the package’s NAMESPACE. Is there a faster or alternative way to make these changes?
I’m willing to manually make the necessary changes and submit a pull request, but I wanted to check if this approach makes sense before committing significant time to it.