Working dir of shiny app when run R rmarkdown document, where shiny is embeded into by `shinyAppDir`

434 views
Skip to first unread message

Shel Kong

unread,
Jul 4, 2014, 11:31:36 AM7/4/14
to shiny-...@googlegroups.com

Hi there,

In shiny apps, the working directory is automatically set to the root directory of the app. And for R markdown, when rendering (also running a shiny doc), the working directory is set to the one which contains the Rmd files.

When I embed a shiny app to a markdown document by shinyAppDir, problems arise: the working directory is set according to the Rmd logic for both R chunks and for shiny app, path I used in shiny apps to import local data need to be changed. In this case I cannot use one app as stand alone as well as embedded one. I can write some code to work around but it becomes complex.

In short, working directory is `APP_ROOT` for shiny apps, but when run as an embedded app in a R markdown, the working directory is different, which is not convenient.

Besides that, I’m considering:

  • how about store some metadata of shiny.app class? For example the app name.

  • I prefer to embed shiny apps into a R markdown document, instead of writing text within shiny apps. In this circumstance, the first problem is the working directory I mention earlier. The next one is, when writing a report, we are usually using the same data set and basic logic, we explore different aspects of a single task. So if I write something and embed a shiny and then write something, I have to embed another shiny app. But the long report may be depend on the same dataset and process. What about one server, many ui.R? It seems that design is now bind to server, but isn’t it the right way to bind design to logic but isolate from server?

Rafael Batista

unread,
Oct 16, 2016, 2:14:28 PM10/16/16
to Shiny - Web Framework for R
Sorry for the delay (2 years?)... can I ask if you know a solution for this?
I am having this problem of different working directories and I dont know what to do.

I am using reference_docx to use some editted styles on Rmd but only works when I knit the document on Rstudio. From inside the app it doesnt work.
Reply all
Reply to author
Forward
0 new messages