Предупреждение в origRenderFunc (): - PullRequest
0 голосов
/ 25 мая 2018

Используя plot_ly, я получил следующее предупреждение:

Warning in origRenderFunc() :Ignoring explicitly provided widget ID "2e241c7bce6b"; Shiny doesn't use them

Из-за этого предупреждения мой график не отображается.Мой вопрос о том, как исправить это предупреждение.Пользователь загружает файл Excel.После загрузки файла пользователь может построить его (я использовал плотно, потому что это очень круто).Пользователь может выбрать то, что может график, который мы хотели бы видеть.У него есть 2 варианта: линия или график рассеяния.

Ниже функции с 3 вариантами графика

plotType <- function(z, type){
    switch(type,
     "Line" = plot_ly(z, 
                      type = "scatter",
                      mode ="lines"),
     "Scatterplot" = plot_ly(z,
                          type = "scatter",
                          mode = "markers")
              )
  }

Мой код пользовательского интерфейса.Пользователь загружает свой файл и затем выбирает переменные, которые он / она хотел бы видеть.

ui <- fluidPage(
  sidebarPanel(
 fileInput(inputId = "file1", label = "Choose CSV File",
          multiple = FALSE,
          accept = c("text/csv",
                     "text/comma-separated-values, text/plain",
                     ".csv")
),
selectInput('xcol', 'X Variable', ""),
selectInput('ycol', 'Y Variable', "", selected = ""),
radioButtons(inputId ="graph", label = "Type of graph:",
             list("Line", "Scatterplot"),
             selected = "Line")
mainPanel(
tabsetPanel( type = "tabs",
             tabPanel(
               # App title
               titlePanel("Uploading Files"),
               # Output: Data file
               tableOutput("contents")
             ),
             tabPanel(
               titlePanel("Plot"),
               plotOutput('MyPlot'))
))))

Мой код подачи

server <- function(input, output, session) {
data <- reactive({
req(input$file1) # require that the input is available

df <- read.csv(input$file1$datapath,
               header = input$header,
               sep = input$sep,
               quote = input$quote)

updateSelectInput(session, inputId = 'xcol', label = 'X Variable',
                  choices = names(df), selected = names(df)[sapply(df, is.numeric)])
updateSelectInput(session, inputId = 'ycol', label = 'Y Variable',
                  choices = names(df), selected = names(df)[sapply(df, is.numeric)])

return(df)
})
output$MyPlot <- renderPlotly({
  x <- data()[, c(input$xcol, input$ycol)]
  plotType(x, input$graph)

})}
...