2017-01-20 1 views
0

私が構築した光沢のあるアプリについて質問があります。私が共有したアプリは、ggplot2パッケージをアップデートするまでうまくいっていました。私はエラー:Error in nearPoints: nearPoints: not able to automatically infer xvar from coordinfoを持っています。なぜそれが働いていたのかわかりませんが、今は効いていません。R shiny:更新後に動的データ選択でエラーが発生するインタラクティブトグルポイント(nearPoints())

このアプリケーションのアイデアは、選択したデータ入力を使用してインタラクティブな散布図を作成することです。

このエラーが発生した理由を知る手助けができますか?ここで

はapp.rです:

library(shiny)  
ui <- fluidPage(
    fluidRow(
    column(width = 6, 
      selectInput("vsselection", "Choose a vs:", 
         choices =  names(table(data.frame(mtcars$vs))),selected=0), 
      plotOutput("plot1", height = 350, 
         click = "plot1_click", 
         brush = brushOpts(
         id = "plot1_brush" 
        ) 
      ), 
      actionButton("exclude_toggle", "Toggle points"), 
      actionButton("exclude_reset", "Reset") 
    ) 
    ) 
    ) 
server <- function(input, output) { 
# For storing which rows have been excluded 
vals <- reactiveValues(
keeprows = rep(TRUE, nrow(mtcars)) 
) 

output$plot1 <- renderPlot({ 
# Plot the kept and excluded points as two separate data sets 
keep <- mtcars[which(mtcars$vs==input$vsselection),][ vals$keeprows, , drop = FALSE] 
exclude <- mtcars[which(mtcars$vs==input$vsselection),][!vals$keeprows, , drop = FALSE] 

ggplot(keep, aes(wt, mpg)) + geom_point(color = "blue") + 
    geom_smooth(method = lm, fullrange = TRUE, color = "black") + 
    geom_point(data = exclude, shape = 21, fill = NA, color = "black", alpha = 0.25) 
}) 

# Toggle points that are clicked 
observeEvent(input$plot1_click, { 
res <- nearPoints(mtcars[which(mtcars$vs==input$vsselection),], input$plot1_click, allRows = TRUE) 

vals$keeprows <- xor(vals$keeprows, res$selected_) 
}) 

# Toggle points that are brushed, when button is clicked 
observeEvent(input$exclude_toggle, { 
res <- brushedPoints(mtcars[which(mtcars$vs==input$vsselection),], input$plot1_brush, allRows = TRUE) 

vals$keeprows <- xor(vals$keeprows, res$selected_) 
}) 

# Reset all points 
observeEvent(input$exclude_reset, { 
vals$keeprows <- rep(TRUE, nrow(mtcars[which(mtcars$vs==input$vsselection),])) 
}) 

} 


shinyApp(ui, server) 

答えて

0

私はそれが1.0.0に "光沢" のパッケージ版を更新することで把握ました。古いバージョンを使用している場合は、警告:Warning in seq_len(nrow(layout)) : first element used of 'length.out' argumentが表示されます。これはパッケージのバージョンと関係があります。

関連する問題