我是新来的闪亮人,现在我正试图在我闪亮的应用程序中绘制巴基斯坦地图。我目前使用的代码在控制台上运行良好,但我不太确定如何在我闪亮的应用程序中实现它。[![控制台输出][1][1]代码:
library(maptools)
library(raster)
adm <- raster::getData('GADM', country='PAK', level=2),
mar<-(adm),
plot(mar, bg="dodgerblue", axes=T),
plot(mar, lwd=10, border="skyblue", add=T),
plot(mar,col="green4", add=T),
grid(),
box(),
invisible(text(getSpPPolygonsLabptSlots(mar), labels=as.character(mar$NAME_2), cex=1.1, col="white", font=2)),
mtext(side=3, line=1, "Pakistan", cex=2),
mtext(side=1, "Longitude", line=2.5, cex=1.1),
mtext(side=2, "Latitude", line=2.5, cex=1.1)
#
这就是我目前在闪亮应用程序中所做的:
**ui.r**
shinyUI(
navbarPage(
inverse = TRUE,
title = "Campaign Launch Demo",
tabPanel("Daily Insights",
sidebarLayout(
sidebarPanel( )
mainPanel(
fluid = TRUE,
uiOutput('map2')
)
)
)
)
)
and this the code for the server script:
**server.R**
shinyServer(function(input, output, session){
output$map2 <-
print(
adm <- raster::getData('GADM', country='PAK', level=2),
mar<-(adm),
plot(mar, bg="dodgerblue", axes=T),
plot(mar, lwd=10, border="skyblue", add=T),
plot(mar,col="green4", add=T),
grid(),
box(),
invisible(text(getSpPPolygonsLabptSlots(mar), labels=as.character(mar$NAME_2), cex=1.1, col="white", font=2)),
mtext(side=3, line=1, "Pakistan", cex=2),
mtext(side=1, "Longitude", line=2.5, cex=1.1),
mtext(side=2, "Latitude", line=2.5, cex=1.1)
) }
[1]:
https://i.stack.imgur.com/ihfvM.png