I'm getting this in one of the sf vignettes:
library(sf)
dem(nc, echo = FALSE)
tmap_mode("view")
# tmap mode set to interactive viewing
tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5))
# Error in as.hexmode(strsplit(lty, "")[[1]]) :
# 'x' cannot be coerced to class "hexmode"
it runs fine in "plot" mode.
Thanks! Fixed, please reopen if necessary.
Thanks for the quick fix, @mtennekes !
I'm getting this in one of the sf vignettes:
library(sf) dem(nc, echo = FALSE) tmap_mode("view") # tmap mode set to interactive viewing tm_shape(nc) + tm_fill("BIR74", palette = sf.colors(5)) # Error in as.hexmode(strsplit(lty, "")[[1]]) : # 'x' cannot be coerced to class "hexmode"it runs fine in "plot" mode.
I am seeing the same error. Can you please provide a bit more detail about the running in "plot" mode work around? My maps are in a Shiny App
Thank you!
Map <- tm_shape(MyMap)+
tm_fill(col="fillCol",
title = " ",
palette = MyColors)+
tm_shape(localMap)+
tm_borders(col = "white")+
tm_layout("My Title", legend.text.size = -0.5)+
tm_text(text = "Name", size = 0.5, group = "Site Names")
Map %>% tmap_leaflet() %>%
setView(lng = -105.10033, lat = 39.6, zoom =9) %>%
addProviderTiles('Esri.WorldGrayCanvas', group='Grayscale Map') %>%
addProviderTiles('OpenStreetMap', group='Street Map') %>%
addMarkers(lng = -105.155927,
lat = 39.746347,
icon = YellowIcon,
label = "Site",
popup = "<b>Program type:</b><br>Ext. Day",
popupOptions = labelOptions(direction = "bottom",
textsize = "8px"))
Error in as.hexmode(strsplit(lty, "")[[1]]) :
'x' cannot be coerced to class "hexmode"
I'm still having this issue, with my own code:
tmap_mode("view")
svi_bg <- tm_shape(chicago_svi) + tm_fill("R_PL_THEME1", style = "Blues")
Error in as.hexmode(strsplit(lty, "")[[1]]) :
'x' cannot be coerced to class "hexmode"
I've tried redownloading tmaps and leaflet, and I still get this message. Map works perfectly well in plot mode. Any ideas?
I had to access the tmap package from the development site rather than from CRAN to load version 2.3-1
Once I installed the new version and restarted R Studio, all was working once again.
https://www.displayr.com/installing-r-packages-from-github/
install.packages("devtools")
library(devtools)
install_github("tmap")
library(tmap)
This process can also be completed in the console.
thanks!!
For me, install_github("tmap") returned error "Error in parse_repo_spec(repo) : Invalid git repo specification: 'tmap'".
install_github("mtennekes/tmap") worked fine, & once installed tmap_mode("view") was working again.
Allison, Did you restart your computer/R Studio?
not after installing from GitHub, is that what you mean?
Yes, I had to restart my computer (thus restarting R). Good Luck
Most helpful comment
I had to access the tmap package from the development site rather than from CRAN to load version 2.3-1
Once I installed the new version and restarted R Studio, all was working once again.
https://www.displayr.com/installing-r-packages-from-github/
install.packages("devtools")
library(devtools)
install_github("tmap")
library(tmap)
This process can also be completed in the console.