Reputation: 6755
I want to include in a Shiny app an interactive document generated from a Rmd. Problem is the Rmd includes two Shiny apps.
This is the .Rmd
# myInteractiveDocument.Rmd
...
```{r, echo=FALSE, eval=TRUE}
shinyAppDir('shiny_app_dir1',
options=list(width= "100%", height=700))
```
...
```{r, echo=FALSE}
shinyAppDir('shiny_app_dir2')
```
and this is the outer Shiny app
library(shiny)
# Define UI for application that draws a histogram
ui <- shinyUI(fluidPage(
...
mainPanel(
plotOutput("distPlot"),
includeHTML("intro.html")
)
)
))
# Define server logic required to draw a histogram
server <- shinyServer(function(input, output) {
...
# Run the application
shinyApp(ui = ui, server = server)
I proceeded in this way:
I compiled the Rmd document with
R -e "rmarkdown::render('myInteractiveDocument.Rmd')"
and moved it to the same folder of the outer app.
When I run it from RStudio everything works. But then when I moved it on a Ubuntu server I get the error
Uncaught TypeError: Cannot read property 'filter' of undefined
raised at this line
var dynamicResults = results.filter(".html-widget-output");
of data:application/x-javascript
Upvotes: 4
Views: 412
Reputation: 7645
Maybe you should try to load the apps as objects. For example
# myInteractiveDocument.Rmd
...
```{r, echo=FALSE, eval=TRUE}
ui1 = source( "path/to/app1/ui.R", local = TRUE )$value
server1 = source( "path/to/app1/server.R", local = TRUE )$value
server( input, output, session )
ui1
```
...
```{r, echo=FALSE}
ui2 = source( "path/to/app2/ui.R", local = TRUE )$value
server2 = source( "path/to/app2/server.R", local = TRUE )$value
server2( input, output, session )
ui2
```
Note that source( ..., local = TRUE )
is basically just like copy/pasting, so the input/output ids of the two apps and the rmd
must not collide in order for this to work.
Upvotes: 1