I am creating a complex RMarkdown document that includes some charts made in ggplot2. I run the following code:
rmarkdown::render(input="U:/John/R/aa_app/output/template.Rmd")
This creates a Word document called "template.docx" with no problem.
However, I need to be able to specify a different file name and location for this document. So I run:
rmarkdown::render(input="U:/John/R/aa_app/output/template.Rmd",output_file="U:/John/R/aa_app/output/test.docx")
or
rmarkdown::render(input="U:/John/R/aa_app/output/template.Rmd",output_file="U:/John/R/aa_app/output/temp/test.docx")
In both cases, a Word document is created called "test.docx" but the charts are missing from the file. I get a series of error messages:
"C:/Program Files/RStudio/bin/pandoc/pandoc" template.utf8.md --to docx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
--output U:/John/R/aa_app/output/test.docx --highlight-style tango
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-3-1.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-3-2.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-4-1.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-7-1.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-8-1.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-8-2.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-8-3.png', skipping...
pandoc.exe: Could not find image `U:/John/R/aa_app/output/test_files/figure-docx/unnamed-chunk-8-4.png', skipping...
Does anyone know what is going wrong?
UPDATE: Here is a reproducible example.
Code for Repro.Rmd:
---
title: "Repro"
author: "John Butters"
date: "Tuesday, April 28, 2015"
output: word_document
---
```{r, echo=FALSE}
plot(cars)
```
If I run the following code, a document is produced called "Repro.docx" that includes a plot of the "cars" dataset.
rmarkdown::render(input="U:/John/R/Repro.Rmd")
However, if I run the following code, a document is produced called "aaargh.docx" that does not include the plot, and I get the same pandoc error as above.
rmarkdown::render(input="U:/John/R/Repro.Rmd",output_file="U:/John/R/aaargh.docx")
"C:/Program Files/RStudio/bin/pandoc/pandoc" Repro.utf8.md --to docx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output U:/John/R/aaargh.docx --highlight-style tango
pandoc.exe: Could not find image `U:/John/R/aaargh_files/figure-docx/unnamed-chunk-1-1.png', skipping...