Integrate another Shiny app via iframe #155
-
DescriptionHello, The Shinyapp runs on its own without any problems when I host it in shinyapps.io or on my server. Everything is displayed correctly. I also tried to integrate the shinyapp differently and include it in survey.qmd as R-chunk like this: shiny::runApp("/srv/shiny-server/app2/app.R” On the Ubuntu server ( Ubuntu 24.04.1 LTS) I have installed Surveydown 0.5.1 Does anyone have an idea where the problem might be? Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hi! Thanks for giving surveydown a try. I'm having a hard time understanding what you're trying to do. It sounds like you're trying to run two different shiny apps at the same time from the same server? Every surveydown survey runs as a shiny app, so you should only have one call to It would help if you could provide code for a simple example of what you're trying to do. |
Beta Was this translation helpful? Give feedback.
-
Okay, I think there might be a couple different things here, making it a bit complicated to figure out how tot fix this. Let me break them apart.
So issue 1) is I think the bigger challenge because even if you get things running on your ubuntu server with all the dependencies installed, you still might run into issues where the pdfs don't show on all browsers. I'm wondering if there is a different way to achieve this though. I think you could get a fully working setup to show pdfs and the table all within Quarto. That is, I don't think you need a shiny app at all for that. So long as your pdfs are viewable from some url, you should be able to embed them and embed a data table inside quarto using quarto tabs directly in surveydown. You can first experiment with just rendering the qmd file to see if it renders properly. That would be my first suggestion - try rendering that locally and see if it works to view the content in the tabs directly within Quarto. If it works locally, then the issue is figuring out what needs to be on your ubuntu server. |
Beta Was this translation helpful? Give feedback.
-
Just to demonstrate that you can do this all inside surveydown, here is a simple example. It embeds a pdf hosted somewhere on the web (I use my CV as a demo), and a data table from the DT package.
---
format: html
echo: false
warning: false
---
```{r}
library(surveydown)
```
::: {#page1 .sd-page}
# Demo survey of embedded pdf and table in Quarto tabs
::: {.panel-tabset}
### PDF
<iframe width="780" height="600" src="https://nbviewer.org/github/jhelvy/cv/blob/main/cv-jph.pdf" title="Information"></iframe>
### Table
```{r}
sd_output('table')
```
:::
Here's a survey question:
```{r}
sd_question(
type = "mc",
id = "like_apple",
label = "Do you like apples?",
option = c(
"Yes" = "yes",
"No" = "no"
)
)
```
:::
library(surveydown)
server <- function(input, output, session) {
# Make data table output widget
output$table <- shiny::renderUI({
DT::renderDataTable({
mtcars |>
DT::datatable()
})
})
# Run the surveydown server
sd_server()
}
shiny::shinyApp(ui = sd_ui(), server = server) One important point to highlight - the creation of the data table widget has to be done inside a call to output$table <- shiny::renderUI({
DT::renderDataTable({
mtcars |>
DT::datatable()
})
}) In the I haven't tested if this works when served live on shinyapps.io or elsewhere, but it runs locally. |
Beta Was this translation helpful? Give feedback.
-
Hi John, The table is a reactable and I had no problems embedding it.
In January, a knowledge test using SurveyDown will be conducted with around 300 participants. I am excited to see how well it works with SurveyDown. |
Beta Was this translation helpful? Give feedback.
-
Oh wow that's great! I just tried it and yes, Glad to hear you'll be using this in January, please do let us know how it goes! |
Beta Was this translation helpful? Give feedback.
Hi John,
thank you very much!
I embedded the data table and the PDFs (iframe) using quarto tabs in surveydown. That works great.
The table is a reactable and I had no problems embedding it.
That's how I did it:
survey.qmd
app.R