Run App Option not showing on the Pane, #R - r

I am learning about shiny dashboards, I am unable to find run app option which comes at the pane where we write our code the run app option is not visible. Kindly assist to enable the same.

For Rstudio to display the run app button, it needs to recognize your script as a shiny app. One of the easiest way in Rstudio would be to go to file --> new file--> Shiny web app, since Rstudio would create the app.R file for you (by now you should see the run app button).
If you are working with a ui.R and server.R file, you should add the following line at the end of your server.R file:
shinyApp(ui = ui, server = server)

Related

R Shiny `options(shiny.autoreload = TRUE)` doesn't work with change in a module script

I am running a Shiny app as a background (local) job by sourcing a run_app.R file which looks like this:
# Run app as a background local job
options(shiny.autoreload = TRUE)
shiny::runApp()
Running this script as a local job allows me to make changes to the app code (server.R or ui.R) and the app reloads automatically in a browser window. However, if I change one of the module files (I have a modularised app), the browser refreshes, but the app doesn't change.
Does anyone have a tip on how to make Shiny autoreload with changes to any app file (not only server.R and ui.R)?

runApp() from shiny is not working from code or RStudio's button

I can not run a shiny app, neither by the RStudio's button "Run App" or directly with the code runApp()
I've been using this shiny app for many years. But recently, without any changes, the app stop working when I press the button "Run App" in RStudio. Then I enter the command runApp() and it doesn't work neither.
When I press the RStudio button "Run App" I get:
runApp('')
Error in shinyAppDir(x) : No Shiny application exists at the path ""
When I enter the command shiny::runApp() at the beginning of the app, I get:
Listening on http://127.0.0.1:3642
Warning: Error in runApp: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
51: stop
50: runApp
Error in runApp() :
Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
The working directory is good.
So, I'm stuck. I can not run the app.
I just realize that the problem happens when I open RStudio opening the app directly; in this case, RStudio automatically recognizes the working directory as the directory where the app is.
But if I open RStudio first (for example, from the Desktop icon) or the working directory is different from the directory where the app is, I don't have any issue: the "Run App" button in RStudio works perfectly.
I think the button depends on the working directory, if the working directory is different from the app directory, the buttom automatically adds the path so the app can run. But, if the working directory is the same as the app directory, the button removes the path, leaving an empty space inside runApp() and then causing the problem.
I've seen the second error before. I was attempting to solve a different problem when I launched a shiny app. There was a button in it which, on click, had the command runApp to launch another shiny app. That's when I got the error.
A shiny app cannot be called from within another shiny app.
Try adding R file path/ name in runApp command. Example: runApp("test.R")
Create a new R file run.R in the same directory as shiny app. In run.R, type this:
library (shiny)
runApp("test.R")
Run this file like a normal R process.
Instead of runApp, use shinyApp(ui = ui, server = server) in the original shiny app.

Shinny (R studio) app doesn't work and doesn't appear "Runapp"

I am working with Library shiny. I was doing a project on my computer and it worked. The project can do a boxplot with a CSV and the inputs are a date and an integer.
I sent the project to my friend so that she could try but she couldn't get the "Run app" icon. She ran the code and she got the ui but it doesn't appear the boxplot when she types the date and the integer.
I tried to reload librarys but it didn't work. I also changed the working directory. Does anybody have a suggestion?
It would be greatly appreciated.
Make sure shiny and all of the library dependencies are installed on her machine.
Make sure Rstudio is updated to the latest version
Sometimes I have had to just simply put a new line in the file and save it again for the run app button to show. but the line that makes that come up would be
shinyApp(ui = ui, server = server)

Modular Shiny app workflow in Rstudio

While developing a modular Shiny app (with multiple .R files that are sourced by global.R) in RStudio I have to repeatedly
switch to ui.R or server.R
click Run App
click Stop
navigate back the R file I'm working on
Doing this many times is a pain as I hardly work on ui.R or server.R files directly. I've looked for a keyboard shortcut for Run App here to no avail.
Typing runApp() in the Console is a workaround. Anything better?
If your question is just for a shortcut for Run App, ctrl + shift + enter (on windows) works in server.R, ui.R, and app.R files.
Edit: In RStudio you can also use ctrl+f9 and ctrl+f10 to navigate across open tabs and then use ctrl+shift+enter to execute.

After installing shinyapps and shiny, RUN and SOURCE botton disappeared, how to get them back?

I'm using R 3.2 and Rstudio 0.98.953
Just installed shinyapps and shiny, and the RUN APP button showed up (some people say it will only appear in preview version of Rstudio 0.99)
But the RUN and SOURCE botton disappeared. Any way I can get them back? Thanks!
Is the currently open file a file in a Shiny app? If RStudio detects that you're in a Shiny app (the file you're viewing is ui.R or server.R or app.R etc.) then it automatically lets you run the shiny app instead of "run the code" because that's the correct thing to do. When you switch to a different file that's outside of a shiny folder, it should go back to normal.
If you're not inside a Shiny app and it's showing "Run App", then you should file a bug with RStudio

Resources