简体   繁体   中英

OpenStreetMaps autoplot error in RStudio Server and Shiny Server in R4.0.0

I am getting a error when trying to plot OpenStreetMaps using autoplot in both RStudio Server and Shiny Server.

require(maps)
require(ggplot2)
require(OpenStreetMap)
mp <- openmap(c(53.38332836757155,-130.517578125),
c(15.792253570362446,-67.939453125),4,'stamen-watercolor')
mp_bing <- openmap(c(53.38332836757155,-130.517578125),
c(15.792253570362446,-67.939453125),4,'bing')
states_map <- map_data("state")
states_map_merc <- as.data.frame(
projectMercator(states_map$lat,states_map$long))
states_map_merc$region <- states_map$region
states_map_merc$group <- states_map$group
autoplot.osmtile 3
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
p <- autoplot(mp,expand=FALSE) + geom_polygon(aes(x=x,y=y,group=group),
data=states_map_merc,fill="black",colour="black",alpha=.1) + theme_bw()

The error is:

Error: Objects of type OpenStreetMap not supported by autoplot.

I'm using version R 4.0.0.

Any insight would be great since this worked fine on R version 3.5.2 just fine on a different Shiny server.

I had the same problem, too. Using OpenStreetMap::autoplot.OpenStreetMap() instead of ggplot2::autoplot() , I managed to obtain an attached image:

附图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM