मैंने सोचा कि यह चमकदार ऐप में साजिशGoogleMaps का उपयोग करने के लिए वास्तव में अच्छा होगा, ताकि आर का उपयोग करके स्थानिक डेटा का गतिशील विश्लेषण और प्रदर्शन किया जा सके। मैंने कभी भी पैकेज का उपयोग नहीं किया है (वे अपेक्षाकृत नए हैं) और अधिक नहीं है प्रोग्रामिंग अनुभव, इसलिए मैंने प्रत्येक के लिए ट्यूटोरियल और उदाहरणों के साथ शुरुआत की और फिर उन्हें एक साथ मैश करने की कोशिश की।चमकदार ऐप में plotGoogleMaps
मैं कोड के सभी व्यक्तिगत तत्वों को काम करने के लिए प्राप्त कर सकता हूं, लेकिन ऐप चलाने से Google मानचित्र प्रदर्शित नहीं होता है। मुझे लगता है कि इसे प्लॉटGoogleMaps के साथ ब्राउज़र में साजिश करने की कोशिश कर रहा है और एक ब्राउज़र में साजिश रेंडर करने की कोशिश कर रहा है, लेकिन मुझे नहीं पता कि इसे कैसे हल किया जाए। मैं the shiny tutorial Inputs & Outputs से चमकदार कोड के सबसे खींच लिया और plotGoogleMaps Tutorial
परीक्षण कोड का पालन किया:
#load packages and data
library(shiny)
library(plotGoogleMaps)
data(meuse)
#convert data frame to SpatialPointDataFrame and set
coordinates(meuse)<-~x+y
proj4string(meuse) <- CRS('+init=epsg:28992')
#will need to select column name for app, maybe not best way to do this,
#but seems to work
formulaText<-paste('zinc')
#plot data on Google map, opens browser and works
mpgPlot <- plotGoogleMaps(meuse, zcol=formulaText)
ui.R
library(shiny)
# Define UI for meuse test
shinyUI(pageWithSidebar(
# Application title
headerPanel("Meuse Test"),
# Sidebar with controls to select the variable to plot on map
sidebarPanel(
selectInput("variable", "Variable:",
choices=list("Zinc" = "zinc",
"Lead" = "lead",
"Copper" = "copper"),
selected="Zinc")
),
# Show the caption and plot of the requested variable on map
mainPanel(
plotOutput("mapPlot")
)
))
server.R
library(shiny)
library(plotGoogleMaps)
data(meuse)
coordinates(meuse)<-~x+y
proj4string(meuse) <- CRS('+init=epsg:28992')
# Define server logic required to plot various variables on map
shinyServer(function(input, output) {
# Compute the forumla text in a reactive expression since it is
# shared by the output$mapPlot ?I think I still need to do this...
formulaText <- reactive({
#paste the input name in so it follows argument format for plotGoogleMaps?
#tried without, don't think it is probelm, works with test code...
paste(input$variable)
})
# Generate a plot of the requested variable against mpg and only
# include outliers if requested
output$mapPlot <- renderPlot({
plotGoogleMaps(meuse, zcol=formulaText)
#also tried to specify alternative arguments like add=TRUE,
#filename='mapPlot.htm', openMap=FALSE
})
})
मैं दोनों को समझने चमकदार और साजिशGoogleMaps बहुत नए हैं और मैंने कुछ सुझाव देखा है चमकदार Google समूह को प्रश्न पोस्ट करें, लेकिन मैं पोस्ट को डबल नहीं करना चाहता हूं और स्टैक ओवरव्लो उत्तर के लिए जाना है। मैं अंत में एक समुदाय में एक छोटा सा योगदान करना चाहता हूं जिसने मुझे अब तक बहुत मदद की है! यह सिर्फ एक घटिया दृष्टिकोण मैं विकल्प के लिए खुला रहा हूँ है, तो मैं अब googleVis बाहर की जाँच कर रहा हूँ ...
धन्यवाद, एलेक्स
PS-
sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] googleVis_0.4.3 plotGoogleMaps_2.0 maptools_0.8-25
[4] lattice_0.20-15 foreign_0.8-54 rgdal_0.8-10
[7] sp_1.0-11 shiny_0.6.0
loaded via a namespace (and not attached):
[1] bitops_1.0-5 caTools_1.14 digest_0.6.3 httpuv_1.0.6.3
[5] Rcpp_0.10.4 RJSONIO_1.0-3 tools_3.0.1 xtable_1.7-1
PPS- मैं this post पढ़ पोस्ट करने से पहले कई बार, लेकिन अब संदेह है कि मेरा जवाब वहां है। यदि प्रश्न डुप्लिकेट है तो माफी माँगें। मुझे लगता है कि यह htmlOutput()
साथ कुछ ... ?htmlOutput
विरल है ... मैं घने महसूस कर रहा हूँ ...
आपके त्वरित उत्तर के लिए धन्यवाद! मुझे 'plotGoogleVis' नहीं मिल रहा है, 'plotGoogleMap' (मैं उपयोग कर रहा हूं) 'googleVis' (मैंने उल्लेख किया है) है ... iframe उपयोगी दिखता है, नया क्षेत्र, मैं कोशिश करूँगा और वापस आऊंगा ... I अगर कोई काम स्वीकार करेगा, तो भी पत्रक के बारे में नहीं पता था। धन्यवाद! –