How to write code and view results at the same time? - r

I am trying to create a rmarkdown document for monthly reports. The issue I have is writing code and trying to visualize what the result would look like in the final document. I can generate and view maps in RStudio but this doesn't show me how they are positioned relative to text and other features within the output document (PDF, HTML etc)
Is there software that exists that allows you to write code in one window and view the product in another as code is developed? At the moment I am knitting the code and viewing the results in a trial and error process. It would be nice to see what the results look like in the document without having to rerun my file each time I change a piece of code and open the output document.
Kind regards,
Simon

If you click the green arrow in the top right of your block of code, it will just run that block of code and won't create a full output file. It will also tell you where an error is if any.

Related

Automatically knit two versions of an Rmarkdown PDF file, one showing and one hiding all code

I am working on a PDF report that includes many analyses, figures and tables, and that needs to be frequently updated. This is read both by people who are interested only in the output (no code), but also by people who want to see the code.
I know I can hide all chunks globally putting knitr::opts_chunk$set(echo=FALSE) at the top of the doc. However, I was wondering whether there is a way to automatically knit two versions of a report, one showing all code chunks, and one hiding them?

rmarkdown interactive time selector

I often create chart reports on rstudio, knit it with rmarkdown and upload it to a private hosting account so I can share the document to be viewedas a webpage on a browser .
However those reports are static, therefore the viewer cannot, for example, select a time period he or she wishes to apply to the chart.
I wonder what would be the best solution, to add an interactive time selector to this rmarkdown document and make it work online.
I would really appreciate any advise for a quick and simple solution to this cenario.
Thanks

Using readline(prompt = "") in rMarkdown

I'm currently attempting to automate some statistical report generation, however to do so I would like to collect a couple of piece of information from the user before beginning, then create a markdown report from it.
When knitting the document however it hangs forever because it has no route to receive the user input from. Does anyone know of one, or would it be a case of using a separate r script to gather the information then using calling the report generation from within that using rmarkdown::render?
You could embed a Shiny app or make use of parameterized reports in the Rmarkdown document. Without further detail (eg some code), it is hard to tell you more.
I hope that this helps, though.

Is there a way for RPubs to automatically re-run the markdown document every time the page is loaded?

I currently have a markdown document which scrapes data from a website and outputs a table using that data. I published the HTML to RPubs using the knit function on Markdown. I'm wondering if there is a way for the table to be updated automatically on RPubs without having to go into R and knitting and publishing the document every day. The data from the website changes every day, so the table changes every day as well.
Thank you!
No, RPubs just takes the static HTML file.
What you want is reactive markdown (using shiny) which you can also host for free. (Though unless you run your own server behind a firewall or pay it will be public)
Here is the tutorial: http://rmarkdown.rstudio.com/authoring_shiny.html
In your case, since you don't actually want it to be reactive, just rerun, I don't think you are going to have to change much of your code.

RMarkdown dynamic hyperlinks

I have been lately busy writing an RMarkdown document that would render a pdf report with information about genetic variants. However, the readers for whom the reports are intended asked whether I could embed a link to the UCSC Genome Browser to view the variant in context. I'm actually looping through the variants in a table and printing the annotations thus:
for i in nrows(table){cat("Region:"}
I know that if I do this:
for i in nrows(table){cat("[Region:](www.somewebsite.com)")}
I can get the word "Region" to become a clickable hyperlink in the final PDF. My problem is that the link should be dynamic (i.e. the link should take the genomic coordinates for that particular variant). I've been looking for hours but can't find a way to do that. Is that possible in R/RMarkdown or should I change my strategy?
Thanks!

Resources