2015-01-28 4 views
1

필자는 markdown에서 rworldmap으로 내 데이터를 사용하여 멋진 맵을 생성 할 수 있지만 Shiny R을 사용하여 구현하는 것은 불가능합니다. 도움을주십시오.라이브러리 "rworldmap"을 사용하여 Shiny R에 플롯하는 방법

내 코드 :

# Join data to a map to create a spatialPolygonsDataFrame 
sPDF <- joinCountryData2Map(comb_mdata, joinCode='NAME', nameJoinColumn='Country') 

par(mai=c(0,0,0.2,0),xaxs="i",yaxs="i") 

mapParams <- mapCountryData(sPDF, nameColumnToPlot='Wt.Score', 
      mapRegion="world", 
      missingCountryCol='dark grey', numCats=10, 
      colourPalette=c('green4','green1','greenyellow','yellow','yellow2','orange','coral','red','red3','red4'), 
      addLegend=FALSE, 
      oceanCol="light blue") 

do.call(addMapLegend, c(mapParams, legendWidth=1.0, legendIntervals="page", legendMar=3)) 

mtext("[Grey Color: No Data Available]",side=1,line=-41) 

답변

1

마지막으로 나는 내 문제를 해결할 수 있었다 이것은 필요로하는 사람에게 도움이 될 수 있습니다 :

ui.R :

mainPanel(
    tabsetPanel(id="tp", 
       tabPanel("Map View", plotOutput("mPlot", height="560px", width="950px")) 
    ) 
) 

server.R :

# Join data frame 'comb_mdata' to the map 
sPDF <- joinCountryData2Map(comb_mdata, joinCode='NAME', nameJoinColumn='Country') 

# Generate the Map 
output$mPlot <- renderPlot({ 
mapParams <- mapPolys(sPDF, nameColumnToPlot='Wt_Score', mapRegion='world', 
          missingCountryCol='dark grey', numCats=10, 
          colourPalette=c('green4','green1','greenyellow','yellow','yellow2','orange','coral','red','red3','red4'), 
          addLegend=TRUE, 
          oceanCol='light blue') 
mtext("[Grey Color: No Data Available]",side=1,line=-1) 
}) 
+0

나 같은 많은 사용자를 저장하면 시간 낭비! –