简体   繁体   中英

Rshiny App displaying wrong script

Please forgive me if this question is not worded efficiently; this is my first time posting a question. I am a writing a Shiny App, and it has been going pretty well until a few days ago. I have encountered a problem where, whenever I run the app, an output is displayed that does not match my app at all. Rather, the output appears to be related to the last script a ran (whatever that may be. Here is my code:

`
library(shiny) library(shinyBS)

shinyUi= fluidPage()

shinyApp(ui = ui, server = server)          

`

and here is my server:

shinyServer(function(input, output, session) {}




shinyApp(ui = ui, server = server)

I have no idea what is causing shiny to display the wrong result rather than the result from the script I am actually running. If anyone has any suggestions on how I could isolate or fix the problem, I would be very thankful.

EDIT: Since my question has been answered, and it turns out that the large majority of my posted code was superfluous, I've gone ahead and stripped it down to the bare bones. That should make it more concise. [

If this app consists of two seperate files Ui.R and server.R and you run it by pressing a button runapp in RStudio, you should remove in both scripts the last line

shinyApp(ui = ui, server = server)

because it runs a shiny app you defined before - this app from the screenshot which is defined in terms of ui and server variables. You should also change the first line in Ui.R from

shinyUi= fluidPage(` to fluidPage(

Now after pressing runapp button the app should work fine.


The other possibility is to overwrite ui and server variables and run it via shinyApp (as a one-file shiny app). Just copy two parts of the app to the same script and then change

    shinyUi= fluidPage( to ui <- fluidPage(

and

server <- shinyServer(function(input, output, session) {

at the end just execute

shinyApp(ui = ui, server = server) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM