2016-04-01 24 views
1

girişine göre çıkışını değişmiyor: Ben kodu çalıştırdığınızda, bana bir statik grafik elde veParlak uygulaması Aşağıdaki kodu kullanarak bir Parlak App oluşturduk

library(shiny) 
ui <- fluidPage(
    selectInput("mr", 
       label="Type of Merchandise", 
       choices=c("Groceries", "WhiteGoods", "HomeGoods","Clothes"), 
       selected="Groceries"), 
    plotOutput("curv") 
) 

server <- function(input, output){ 
    output$curv <- renderPlot({ 
    ggplot(new, aes(x=Year, y=Sales, colour = input$mr)) + 
     geom_point(alpha=.3) + 
     geom_smooth(alpha=.2, size=1) + 
     ggtitle("Fitted curve for overall sales") 
    }) 
} 

shinyApp(ui = ui, server = server) 

girişine göre değişmez . Ne elde etmeye çalışıyorum giriş "Bakkal" olduğunda, arsa bu giriş için satış verilerini göstermelidir. Ama bu durumda güncellenmiş değil. İşte çıkışın ekran görüntüsü: enter image description here

kullanıyorum veri kümesi ise:

structure(list(Merchandise = structure(c(4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L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 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 9L, 10L), .Label = c("Shop01", "Shop02", "Shop03", "Shop04", 
"Shop05", "Shop06", "Shop07", "Shop08", "Shop09", "Shop10"), class = "factor"), 
    Year = c(2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
    2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
    2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
    2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
    2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2014L, 2014L, 2014L, 
    2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
    2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
    2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
    2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
    2014L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 
    2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 
    2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 
    2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L, 
    2013L, 2013L, 2013L, 2013L, 2013L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
    2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
    2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
    2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
    2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
    2011L, 2011L, 2011L, 2011L), Total.Sales = c(45547000, 28775000, 
    17029000, 28827000, 38929000, 10740000, 15008000, 10013000, 
    14556000, 10669000, 14334000, 6521000, 30025000, 5899000, 
    5333919, 1915000, 8312000, 4053000, 3506000, 3492000, 11601000, 
    7730000, 7519000, 14426000, 7046000, 1875000, 7902000, 6775000, 
    6063000, 15843000, 19047000, 8250000, 21218000, 7161000, 
    6812000, 1728000, 9807000, 5543000, 5012000, 4790000, 71817000, 
    43940000, 35523000, 56430000, 70254000, 19149000, 28253000, 
    133249000, 27730000, 25198000, 15233000, 10179000, 24703000, 
    9482000, 8850000, 2800000, 11749000, 8734000, 7753000, 7698000, 
    10135000, 9094000, 8669000, 11978000, 8438000, 2391000, 9526000, 
    7978000, 8791000, 13948000, 18087000, 8626000, 21835000, 
    6935000, 6134000, 2380000, 9306000, 5787000, 4388000, 4755000, 
    80738000, 43987000,00, 54873000, 73234000, 18765000, 
    38748000, 103439000, 36943000, 27176000, 12348000, 95600000, 
    18047000, 9104000, 8190000, 2096000, 9719000, 7557000, 7503000, 
    6918000, 7530000, 5456000, 5452000, 7459000, 5218000, 1615000, 
    5613000, 4532000, 4147000, 6534000, 18168000, 7462000,00, 
    5819000, 5733269, 1994284, 8622000, 5745984, 4532426, 4395000, 
    71823000, 38904000, 35842000, 57027000, 52850000, 19012000, 
    28645000, 0, 0, 0, 10408000, 7429000, 10915000, 6997000, 
    5571000, 1559000, 8543000, 0, 0, 0, 7314000, 5396000, 5041000, 
    9620000, 4468000, 1304000, 5426000, 0, 0, 0, 13694000, 7615000, 
    20337000, 7569000, 6201000, 135200, 8673000, 0, 0, 0, 65325000, 
    47179000, 29659000, 37861000, 58183000, 16129000, 23828000, 
    0, 0, 0, 13237000, 8825000, 13981000, 7841000, 4597000, 1155589, 
    13109000, 0, 0, 0, 6412000, 4998000, 4776000, 8306000, 5749000, 
    1539000, 6013000, 0, 0, 0, 16683000, 6223000, 17941000, 5740000, 
    4019000, 1453000, 7130000, 0, 0, 0), Latitude = c(-37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632, -37.8594, -37.8532, -38.3697, -34.3698, -33.4187, 
    -31.0025, -28.8214, -42.8826, -27.405, -28.0632, -37.8594, 
    -37.8532, -38.3697, -34.3698, -33.4187, -31.0025, -28.8214, 
    -42.8826, -27.405, -28.0632, -37.8594, -37.8532, -38.3697, 
    -34.3698, -33.4187, -31.0025, -28.8214, -42.8826, -27.405, 
    -28.0632), Longitude = c(144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859, 144.7994, 147.5463, 
    142.4617, 150.6471, 149.5702, 150.1511, 153.26, 147.3216, 
    152.4424, 148.2859, 144.7994, 147.5463, 142.4617, 150.6471, 
    149.5702, 150.1511, 153.26, 147.3216, 152.4424, 148.2859, 
    144.7994, 147.5463, 142.4617, 150.6471, 149.5702, 150.1511, 
    153.26, 147.3216, 152.4424, 148.2859)), .Names = c("Merchandise", 
"Stores", "Year", "Total.Sales", "Latitude", "Longitude"), row.names = c(NA, 
-200L), class = "data.frame") 

i kodundan bir şey eksik? Burada herhangi bir yardım derinden takdir edilir.

+0

Verilerinizi girdiye göre filtrelemediniz, bu nedenle her zaman tüm satış verilerini çiziyorsunuz. –

+0

Cevabınız için teşekkür ederiz. Filtreyi nereye ekleyebilirim? Üzgünüm, buna yeniyim. –

cevap

1

İşte bir çalışma sürümü. new[new$Merchandise==input$mr,], verileri seçiminize göre filtreler. Ayrıca bazı sütun adları eşleşmiyor ve onları değiştirdim.

library(shiny) 
library(ggplot2) 

ui <- fluidPage(
    selectInput("mr", 
       label="Type of Merchandise", 
       choices=c("Groceries", "White goods", "Home goods","Clothes"), 
       selected="Groceries"), 
    plotOutput("curv") 
) 

server <- function(input, output){ 

    output$curv <- renderPlot({ 
     ggplot(new[new$Merchandise==input$mr,], aes(x=Year, y=Total.Sales)) + 
      geom_point(alpha=.3) + 
      geom_smooth(alpha=.2, size=1) + 
      ggtitle("Fitted curve for overall sales") 
    }) 
} 

shinyApp(ui = ui, server = server) 
+0

Giriş için teşekkürler. Ancak, şimdi boş bir arsa alıyorum. Yapmam gereken bir şey var mı? –

+0

Burada düzgün çalışıyor. Veri çerçeveniz 'new' adlı ve doğru bir şekilde okunuyor mu? Sütun adlarının eşleştiğinden emin olun. –

+0

Sadece 'new' çalıştırılarak kontrol edildi ve içindeki verilerin görüntüleniyor. Sütun adları da eşleşiyor. Neden hala bana gri boş bir arsa veriyor bilmiyorum. –