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

Any plans to create the R equivalent of this repo? #32

Open
p0bs opened this issue Nov 14, 2023 · 2 comments
Open

Any plans to create the R equivalent of this repo? #32

p0bs opened this issue Nov 14, 2023 · 2 comments

Comments

@p0bs
Copy link

p0bs commented Nov 14, 2023

Apologies if this has been answered elsewhere, but I've looked around and haven't seen it.

In the About section of this repo, you state that it is a "Quarto extension to embed Shinylive for Python applications".

Whilst I've seen quarto-webr (A "Quarto Extension to Embed webR" into associated Quarto goodness) and r-shinylive ("An R package for exporting Shiny applications as Shinylive applications"), are there any plans to create the R equivalent of this repo (i.e. a "Quarto extension to embed Shinylive for R applications")? Or am I just missing something obvious?

Thank you for all your terrific work in this area.

@georgestagg
Copy link
Collaborator

Apologies, the main repo documentation is a little out of date. This Quarto extension should now also support adding R Shiny apps in a Quarto document, using something like the following snippet in your Quarto source:

```{shinylive-r}
#| viewerHeight: 600
#| standalone: true

library(shiny)
library(datasets)
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
ui <- fluidPage(
  titlePanel("Miles Per Gallon"),
  sidebarLayout(
    sidebarPanel(
      selectInput("variable", "Variable:",
                  c("Cylinders" = "cyl",
                    "Transmission" = "am",
                    "Gears" = "gear")),
      checkboxInput("outliers", "Show outliers", TRUE)
    ),
    mainPanel(
      h3(textOutput("caption")),
      plotOutput("mpgPlot")
    )
  )
)

server <- function(input, output) {
  formulaText <- reactive({
    paste("mpg ~", input$variable)
  })
  output$caption <- renderText({
    formulaText()
  })
  output$mpgPlot <- renderPlot({
    boxplot(as.formula(formulaText()),
            data = mpgData,
            outline = input$outliers,
            col = "#75AADB", pch = 19)
  })
}
shinyApp(ui, server)
```

@p0bs
Copy link
Author

p0bs commented Jan 19, 2024

Belated thanks for this, George.

With this, I'm looking forward to being able to create a blog post on my Netlify site that can contain its brief spiel and a shinylive app (which imports the relevant data from, say, https://github.com/p0bs/.../raw/.../data.rds).

I sense that the only missing part is my understanding of how all the pieces fit together (which is up to me to solve, given the good documentation already in place)!

Many thanks again.

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

2 participants