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

I am trying to create a brilliant app. I wanted to start from scratch, so starting very simply. Now, when I try to run my application, it works first, but the application instantly freezes, and this error appears:

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

I thought I was wrong, so I tried it with an example from a brilliant textbook. But then again, the same mistake.

Here are my files:

ui.R

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

server.R

 setwd("/home/User") library(shiny) shinyServer( function(input, output) { }) 

With runApp("ws") I get an error.

Any help is appreciated, thanks.

+3
source share
1 answer

Your directories are confused. If you run runApp() in a separate R file, in which you include a directory that will fix your problem, since you just need to specify the name of the folder containing ui.r and server.r . To follow 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 these two are in the Test folder. Create another R file that contains only the runApp() function. This is convenient if you want to run your brilliant application from a separate file (or you can force it to use the port of your choice), which gives you more control.

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

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

Here I saved server.r and ui.r in the same test folder, then I indicated which folder this folder is in, and ran it just by specifying the name of your brilliant application.

+7
source

Source: https://habr.com/ru/post/986296/


All Articles