4

I have created several shiny apps to embed in single Rmarkdown file. I am using Amazon ec2 Ubuntu machine for hosting my shiny apps and rstudio. All the working apps are at /srv/shiny-server.

To do this, I create another folder for Rmarkdown single file in /srv/shiny-server. The individual chunks are running but Run Document commands is giving an error:

ERROR: cannot open the connection

I am using following R markdown code:

### App 1 goes here
    ```{r, echo=FALSE}
library(shiny)
shinyAppDir(
  "/srv/shiny-server/App1",
  options=list(
    width="100%", height=550
  )
)
```
### App 2 goes here
    ```{r, echo=FALSE}
library(shiny)
shinyAppDir(
  "/srv/shiny-server/App2",
  options=list(
    width="100%", height=550
  )
)
```
## Likewise ...
Mithilesh Kumar
  • 256
  • 1
  • 3
  • 18

1 Answers1

1

Not sure this will answer your question, but I encountered this problem and here's what I found. I'm running a shiny server on an Ubuntu EC2 instance. Also, I didn't create shiny apps the same way you did, instead I embedded interactive visualizations in R Markdown using ggvis and the shiny runtime like so:

---
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
  html_document:
    theme: readable
    toc: yes
    toc_depth: 3
runtime: shiny
---

Here are the two things that caused my problem:

  1. Wrong paths to sourced code or data. You can provide absolute paths or paths relative to where your Rmd is located.
  2. Using cache = TRUE in code chunks.

You can't cache things and when you do it causes the "cannot open the connection" error.

Erin Shellman
  • 3,553
  • 4
  • 21
  • 26
  • 1
    It can be a hack to desired output, but it is not answering the fundamental question of simply integrating two apps into a Rmarkdown file. – Mithilesh Kumar Jan 06 '16 at 09:30