Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to run a simple Shiny app? #7

Closed
joshcullen opened this issue Jul 24, 2024 · 2 comments
Closed

Possible to run a simple Shiny app? #7

joshcullen opened this issue Jul 24, 2024 · 2 comments

Comments

@joshcullen
Copy link

This seems like a really great extension, especially for teaching purposes!

Not sure if it's possible to run a Shiny app with the way things are set up, but I received a Error in utils::browseURL(appUrl) : 'browser' must be a non-empty character string and wasn't able to resolve the error by specifying shinyApp(ui, server, options = list(launch.browser = TRUE)). Do you know if there's an argument that can be specified to resolve this? Below is the example code I used for the app:

library(shiny)

ui <- fluidPage(
  titlePanel("Old Faithful"),
  sidebarLayout(
    sidebarPanel = sidebarPanel(
      sliderInput(inputId = "bins", label = "Number of bins:",
            min = 1, max = 50, value = 30)
    ),
    mainPanel = mainPanel(
      plotOutput("distPlot")
    )
  )
)

server <- function(input, output, session) {
  
     output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      wait <- faithful[, 2] 
      bins <- seq(min(wait), max(wait), length.out = input$bins + 1)
      
      # draw the histogram with the specified number of bins
      hist(wait, breaks = bins, col = 'darkgray', border = 'white')
   })
     
}
@coatless
Copy link

coatless commented Jul 24, 2024

@joshcullen approach to be taken would likely be to use the {quarto-shinylive} extension and create a code cell that has the editor and viewer components, e.g.

```{shinylive-r}
#| standalone: true
#| components: [editor, viewer]

# app code from your example
```

Alternatively, you can embed the shinylive editor website directly into a presentation, c.f.

## shinylive REPL

```{=html}
<iframe allow="cross-origin-isolated" style="display:block; margin: 0 auto;" width="90%" height="75%" src="https://shinylive.io/r/editor">
</iframe>
```

Swap the src part of the iframe with the shinylive app share URL if needed.

@georgestagg
Copy link
Member

georgestagg commented Jul 25, 2024

Yes, I definitely think the right way to do this is using shinylive, as @coatless describes above.

The intention for this extension is really just to provide a simple scratch pad for impromptu scripting, rather than supporting complex applications such as Shiny apps. For that reason I'm going to close this issue in favor of pointing towards the quarto-shinylive extension.

EDIT: The quarto-shinylive GitHub readme doesn't make it clear, but it also works with R Shiny apps. Updating the docs to reflect this is on our radar.

@georgestagg georgestagg closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants