I know that it's impossible to put shiny app in pdf latex directly, but I've heard (How to embed an interactive shiny plot in a pdf / presentation? (via knitR maybe) HubertL's answer) it's possible to bind it via link. Can someone help me with that? I haven't found anything about this. I'm using beamer Madrid (Idk if it's important).
You have to publish the Shiny app first. Once you have got the URL to the online app, you can use knitr::include_url() to include an automatic screenshot of the app in non-HTML output formats. See https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html for more information.
Note that this feature currently requires the webshot package and PhantomJS:
install.packages("webshot")
webshot::install_phantomjs()
Related
It is fairly easy to embed tweets into blog post using the blogdown R package and Hugo shortcodes as described at https://bookdown.org/yihui/blogdown/content.html.
I would like to embed tweets in an R markdown document that is being knit to a standalone HTML document. What is the best way to do this? It looks like Twitter provides an Embed Tweet functionality that I can use interactively to get HTML to embed a tweet, but I need to do this programmatically, given a tweet id.
For people who don't want to go to twitter, the thread includes recommendations for two packages. twittrmd and twitterwidget. I was able to get twittrmd to work as follows:
Install packages
This was the hard part, because the CRAN webshot2 repo wasn't compatible with my R environment.
devtools::install_github("gadenbuie/tweetrmd")
# necessary if your output type is not html (as far as I can tell)
devtools::install_github("rstudio/webshot2")
# this is a webshot2 requirement
install.packages("magick")
Use packages
With these packages you can capture a screenshot by
library(twittrmd)
include_tweet("https://twitter.com/nomadj1s/status/1294390352904966151")
If your output type is not html, tweetrmd will rendered as a png or pdf. In any case, I think you can only see the tweet upon knitting.
More info is available on the github, including helper functions to build twitter urls from a username and tweet_id and ideas about how to use memoise to keep a copy of the tweet in the case that it's removed from twitter.
By "directly" I mean not by uploading the app and then using knitr::include_app, but rather entering the source code of the app itself into the Bookdown document.
Rmarkdown supports this, but neither this approach, nor this seems to work with Bookdown. (The former gives an "Error: path for html_dependency not provided" error, the latter displays an empty frame.)
I have found this latex template,
http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/ThesisStyle/
which is perfect for my thesis. I am currently writing it directly in Latex with TexStudio, and playing around with the template directly is easy.
I am however switching to RStudio and wiriting it as a RNotebook, as I need to be able to easily produce docx versions of it (or other formats).
I already produced a Rmd version which works perfectly as a html/docx, but the pdf it produces (and i tried bookdown, thesisdown, oxfordown etc..) is never as good looking as the template above.
Is there a way to "extract" a template from the latex template in the link, which can be used for the pandoc conversion in RStudio? How?
(i am quite a newbie so please try with an easy accessible answer!)
I need to embed gvisMotionChart into an R markdown file and find an example interactive which is really helpful. However when it comes to the googlevis plotting I keep getting this error when I press the "run code" button:
connection to openCPU failed:
error
undefined
NetworkError: A network error occurred
Can anybody figure out the solutions?
Thanks in advance.
The googleVis package creates the javascript that has to be embedded into an HTML document in order for the interactive plot to run on a webpage. You won't be able to get it to work in the console or in Rstudio for that reason. The only way to know for sure if it's working is to knit it to HTML, and then publish it to Rpubs (or anywhere else online). Once it is online it will work. Depending on your browser settings, you might be able to get it to work by opening the HTML locally, but the browser often blocks the embedded plot when opened locally.
Without seeing your actual code, I can't provide you with anything more specific than that.
EDIT: I thought I would add that several months ago I made a markdown file detailing interactive plots in R for a class. You can find it here: http://rpubs.com/crmhaske/uwloo670_Interactive_Plots
If you scroll down to the very end you'll see the example I did using gvisMotionChart. You have to make sure the place where you print the graph is in it's own chunk, and that results is asis:
```{r results='asis'}
print(p,'chart')
```
I have produced a plot using the ggvis package in R. The plot is interactive which can be changed by moving around the slider. However when I save it, it is just a picture of current status without sliders.
I have seen people posting these interactive plots on the website, so I think there should be a way to save it first. How can I do this?
From the Rstudio page for ggvis:
Note: If you’re viewing the HTML version of this document generated with knitr, the examples will have their interactive features disabled. You’ll need to run the code in R to see and use the interactive controls.
From this and the whole page I gather that sharing the interactive graphics can be done using Shiny Apps and/or R Markdown documents. To deploy either of those to people who do not have R installed you need to a) use Shiny Apps IO; or b) install Shiny Server, which has a free version with very basic administration capabilities, and a paid version for confidential information in corporate environment (which I'm only mentioning in case you are not allowed to share your data).
Either way, read through the Shiny Tutorial, the
R Markdown Tutorial, and the combination.