r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
868 stars 121 forks source link

v4 using global environment variable 'temp'? #925

Closed tylerreed11 closed 3 months ago

tylerreed11 commented 3 months ago

I'm not enough of a programmer to know if this is a bug or my poor naming conventions bearing fruit, but I will often use objects called temp in procedures and I've never run into an issue with any packages until now.

library(tmap)
#works
tm_shape(World) +
    tm_polygons(fill = "HPI", 
                fill.scale = tm_scale_intervals(values = "purple_green"), 
                fill.legend = tm_legend(title = "Happy Planet Index"))
#fails
temp = 'asdf'
tm_shape(World) +
    tm_polygons(fill = "HPI", 
                fill.scale = tm_scale_intervals(values = "purple_green"), 
                fill.legend = tm_legend(title = "Happy Planet Index"))
#Error in temp$legnr : $ operator is invalid for atomic vectors
mtennekes commented 3 months ago

Great catch! I had exists("temp") somewhere not realising it also checked the global environment... Fixed.