I have an R Markdown script that takes more than two hours to run.
Sometimes I just want to make a small modification and knit it again to a pdf, but it seems like a waste of time to run the whole script for hours just for that little change.
Is there any way I can "save" what I've already knitted, so that when I knit again with a small change, it can knit only the part where it's changed?
Related
The generation of the epub option for bookdown is not making table captions correctly. Every table has the markdown label also showing in the table caption. This occurs for tables that are basic markdown tables and tables that are generated from kable in a knit chunk. Here is an example output. As you can see, the reference in the text is good, but the caption should read Table 2.4: Time of arrivals and service times for 8 customer. But, instead, it is showing the chunk label (#tab:ArrServTime). The PDF output does not have this problem, nor does the HTML output. It is occurring only in the epub ouput. Since this is occurring in every table, I am wondering if this is a bug or some configuration option that I am missing.
Has anyone else experienced this issue? Is there a work around?
I have a word document with notes from a class. In this document there are images (screenshots from the lecture). I am hoping to make a book, hopefully in bookdown, to help me organize my notes and my R code. I used pandoc to convert the word document and extracted the images, but only some of the images are showing up when i knit the markdown output in RStudio. Any idea why some would show and some wouldnt? COuld it be because i'm changing the .md that pandoc gives to .rmd and they just dont play well together?
When I knit PDF on RStudio. It DOES NOT match what is in my Rmd file after source of the .Rmd. This has happened every time I tried to Knit PDF. How can I get example what is in my .Rmd into Knit PDF? I've tried clearing cache and restarting RStudio but this inconsistency is still happening...
You need to set.seed() at instance where you are generating random data if you are generating any.
Try to clean your environment and rerun and assess results
Try to set.seed at the top of the code and rerun.
I'm working on a rather long code using R markdown, divided into chunks. Plot appear under the appropriate chunk. I'd like to keep this behaviour, but additionally I want to save them to a specified folder. I've tried different methods listed here How to save a plot as image on the disk? (and elsewhere on the Internet), but nothing seems to work.
My reproducible example:
png('cars_plot.png')
plot(cars)
dev.off()
This code saves the plot, but doesn't show it (it only returns "null device 1"). I've also tried dev.print and dev.copy, with the same result.
Thank you in advance!
Clarification: I run my chunks one by one, I don't want to convert my results to pdf/html yet. So knitr: include figures in report *and* output figures to separate files or change where rmarkdown saves images generated by r code don't answer my question.
You can always graph it twice in the same markdown chunk, like this:
plot(cars)
png('cars_plot.png')
plot(cars)
dev.off()
If I have an R block in an Rmarkdown notebook, the code is visible in the rendered nb.html file. However, if I have a SQL block, I can't find a way to make the code visible in the rendered file.
However, if I generate an html_document (standard knitr) instead of an html_notebook, the rendered HTML does include the SQL code (and output).
Is there a way to get the notebook output to do something closer to what the knit output does?
I've also encountered this recently, Harlan, and began by asking if there's a way to get notebook output more like knit output.
I then wondered if there was a way to get knit output more like notebook output and realised that there was.
After asking the folks at RStudio, I learnt that you can add the following line to the YAML options in order to generate a html_document that, when rendered, enables the RMD to be downloaded. Specifically, use:
output:
html_document:
code_download: true
I now use that in all of my code and it works well. I hope it helps you, too.