How to integrate shiny in bookdown - r

How to include a shiny app in a bookdown document? There is an example for including the miniUI in the documentation, but not on how to include an own app.
I tried to include "myapp" in the subdirectory "myapp" either as an integrated file (app.R) or as the two files server.R and ui.R using include_app("myapp") or runApp("myapp"), but this doesn't work.

This question was asked a while back, but I will provide an answer in case anyone else is trying to set this up.
Both functions knitr::include_app() and knitr::include_url() require an URL, which should be the address to the website where you publish your Shiny app. So if you want to build your own app, I suggest you first publish it to the web, and then embed it into the HTML code produced by bookdown using the instructions found here: https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html. Basically, you will need to:
Create a free account at shinyapps.io,
Publish Shiny app (with or without the miniUI package package) following instructions here: https://docs.rstudio.com/shinyapps.io/index.html and
Run the function knitr::include_app() to integrate your Shiny app into your bookdown, as decribed here https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html..
With a FREE account at shinyapps.io, you can publish up to 5 apps. I recommend you try the miniUI package to publish your Shiny app, because it will make the app easily fit into the HTML page generated by bookdown.

Related

Is that possible to retrieve shiny app source .R files from shinyapp.io?

This is related to corrupted files recovery (RStudio R File Corruption)
Is that possible to see (retrieve) source .R and .Rmd files of the Shiny App that was deployed shinyapp.io?
Lets say - you have just successfully uploaded/deployed your Shiny app to shinyapp.io and then your shiny app code got corrupted on your local machine. Can you recover it from deployed codes?
As mentioned in the comment above, if you deployed your code to shinyapps, you are lucky, all your codes are there!
See this article: https://support.posit.co/hc/en-us/articles/204536588-Downloading-your-application-from-shinyapps-io

How to link a Shiny App uploaded in the browser and a Rmd?

I have developed a shiny app with some sections which produce some results. There is another section with the option of download, in HTML format, the plots done in the app. When I am in the R environment it works, but it works because i have the shiny app file .R and the R markdown file .Rmd in the same folder. But when I upload the app in the browser, this link between the shiny app and the r markdown is lost. Is there a way to link both so someone without the Rmd document and without even having R Studio downloaded can use the app and download the plots in an HTML?
I am trying to find some option in shinyapps.io (i guess there's the place where they can be linked) but with no success. Thank you.
Edition: I'm trying something like that https://shiny.rstudio.com/gallery/download-knitr-reports.html
But in this example, it doesn't matter where and what is the R Markdown file?
I have solved the problem. Being in the RStudio environment, when one want to publish the app, in the window "Publish to Server", in the box "Publish Files From", there must be the two files, the .R file where the shiny app code is and the .Rmd where the code for the HTML download is.

Where to put loaded packages and user defined functions in a shiny app script?

so I'm building a shiny app and when I deploy it to shinyapps.io I get several errors. I suspect the organization of my app script is faulty because I include the "library(package)" commands in the script, as well as all my user defined functions. Should I be placing the loading of packages and my used defined functions in a separate script from the app? and if so, how can I do it?
Thanks so much for any response in advance

Creating a Front end with R

I am storing my data in S3 bucket provided from Amazon. I am performing analytics in R studio by creating instance.
I am storing my desired result back in my S3 bucket.
I would like to create an front end in visual studio for my results in R. Could anyone guide me on how I could proceed with this ?
I have created the AWS explorer in visual studio.
Any lead and guidance for this idea would be helpful.
But seriously, take a look at shiny
Plagiarizing from that link: "Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions."
Options (not in any order):
Shiny is an R package that makes it easy to build interactive web apps straight from R
If front-end is all about reports/dashboard, you can push your results in ElasticSearch and then use Kibana on top to present the results as a dashboard.
HIH

Parameterized Rmarkdown document on Shiny application

I want to build a Shiny application where the user can select the input, select output format and click a button to download the report. There are 2 link I think could solve the problem:
http://rmarkdown.rstudio.com/developer_parameterized_reports.html
This link seems exactly what I want but the sample code is use for RStudio environment, I don't know to publish it as a Shiny app in Shiny Server.
http://shiny.rstudio.com/gallery/download-knitr-reports.html
This is the demo from RStudio for Shiny app but I still do not understand how the Shiny app pass parameter to the Rmarkdown document in order to compile the document.
Would someone explain it clearer with an working example.
There was already a question I think is similar to mine here but there was none answer:
How to link rmarkdown report with shinyapps to export webapp content in R?

Resources