Error in handlers$add(handler, key, tail) : Key / already in use with Shiny

前端 未结 1 1708
时光取名叫无心
时光取名叫无心 2020-12-19 22:50

I try to build a shiny app. I wanted to start from scratch, therefore starting very basic. Now when I\'m trying to run my app, at first it seems to work, but instantly the a

相关标签:
1条回答
  • 2020-12-19 23:22

    You got your directories mixed up. If you run runApp() in a separate R file where you include the directory that would fix your problem, as you just have to specify the name of the folder containing ui.r and server.r. To follow on your example below:

    ui.R

    library(shiny)
    
    # Define UI for application that draws a histogram
    shinyUI(fluidPage(
      titlePanel("Test"),
    
      sidebarLayout(
        sidebarPanel("sidebar panel"),
        mainPanel("Data")
      )
    ))
    

    server.R

    library(shiny)
    shinyServer(function(input, output) {})
    

    Now those two are in the folder Test. Create another R file that only has the runApp() function in it. This is handy if you want to run your shiny app from a separate file (or you can force it to use a port of your choosing), giving you more control.

    Your Run file (you can call it whatever you want)

    library(shiny)
    setwd("C:/Users")
    runApp("Test")
    

    Here I saved the server.R and the ui.R in one folder Test, then I specified what directory that folder is in and ran the program, just by specifying the name of your shiny app.

    0 讨论(0)
提交回复
热议问题