Reputation: 147
I think I have a MikTeX problem. In RStudio I clicked on the Knit PDF button and received this error message.
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9 64-bit)
pdflatex: The memory dump file could not be found.
pdflatex: Data: pdflatex.fmt
I then followed the first instruction at http://docs.miktex.org/manual/formats.html Then I rebooted my computer.
At this point I do not know if I need to add a memory dump file and if so, the details of how to do so.
I then tried Knit Word and that worked beautifully, producing a Word 2007 document.
I am using RStudio. I have an R markup document Ira.Rmd. It produced files Ira.md and Ira.html. I would like to save as Ira.pdf. I downloaded and ran pandoc on the command line with
pandoc Ira.md –o Ira.pdf.
I received the following error message.
Pandoc: Error producing PDF from TeX source. This is pdfTeX, Version 3.1415926-2.3.1.40.12 Pdflatex: The memory dump file could not be found. Pdflatex: Data: pdflatex.fmt
Can someone explain in simple terms how I can perform this file conversion? I am using the following.
Windows 7. R Version: 3.0.2 RStudio Version: 0.98.684
I did read https://github.com/rstudio/rmarkdown but I still do not understand how to convert my file.
UPDATE I am editing my question.
I am trying to convert an R markdown file to PDF. I created the RMD file in R Studio. With a click of a button I successfully produced the HTML file which is filled with R code.
I am using R version 3.0.2
I am using RStudio version 0.98.684
I do not know if the following is relevant.
My .Rprofile file contains the following line.
setwd("C:/Users/Ira/Documents/Statistics")
I ran the following
> getwd()
[1] "C:/Users/Ira/Documents/Statistics"
I have attempted all of the suggestions. Thank you. However, I continue to receive error messages when trying to convert to PDF. My most recent posts attempted to post the error messages.
The real Rmarkup file is: IraAppliedStats.Rmd
Clicking on Knit produces the desired HTML file.
I successfully ran the commands:
install.packages("devtools"); devtools::install_github("rstudio/rmarkdown")
library(rmarkdown)
From the console I ran the following command, but I received an error.
render(input = "toPDF2.rmd", output_format = "pdf_document", output_file = "toPDF2.pdf")
I observed the monitor. After a few chunks were produced I started to see multiple messages such as the following after a few chunks were completed.
*Warning in (if (out_format(c("latex", "sweave", "listings", "markdown"))) sanitize_fn else str_c)(path, : dots in figure paths replaced with _ ("IraAppliedStats_Rmd_files/figure-latex/unnamed-chunk-10")*
Also each chunk had the following message.
ordinary text without R code
Much of the document is R code. The same line appears when I am producing the HTML file.
The essence of the error message seems to be.
pandoc.exe: Error producing PDF from TeX source. This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9 64-bit) pdflatex: The memory dump file could not be found.
Using Notepad, I then added the following two lines to the top of the IraAppliedStats.md file.
*title: IraAppliedStats.md output: pdf_document*
I closed Notepad.
I again ran the command.
render(input = "IraAppliedStats.Rmd", output_format = "pdf_document", output_file = "IraAppliedStats.Rmd.pdf")
This did not appear to help as I again received an error message and there was no PDF file produced.
End of addition/edit
Upvotes: 3
Views: 13718
Reputation: 42293
Using the rmarkdown package (included with RStudio Version 0.98.682, the current preview release) it's very simple to convert Rmd to PDF, there is a single function that will do the conversion: render
.
Here's my markdown file (the example one that is created when you start a new Rmd in RStudio), Assume it's called Untitled.Rmd
and saved in the working directory (and assuming your LaTeX distribution is fully up-to-date, and you have the latest version of Pandoc):
---
title: "Untitled" # you must have lines similar to these in your Rmd file
output: pdf_document # this is how R knows to convert this file to a PDF
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. Click the **Help** toolbar button for more details on using R Markdown.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Then I run in the console:
library(rmarkdown)
render("Untitled.Rmd") # you could also use "Untitled.md"
And then I get Untitled.pdf
in my working directory, which looks like this:
Alternatively, here is the long-hand way to do this, if you can't use that version of RStudio, or don't want to include those title:
and output:
lines in your markdown code:
# Load packages.
require(knitr)
require(markdown)
# Process your .Rmd and generate a .pdf file
# (including smart punctuation and grey background of code blocks)
# For this step you'll need to have two other programs installed on your computer
# 1. Pandoc: http://johnmacfarlane.net/pandoc/installing.html
# 2. LaTeX: follow the instructions on the Pandoc download page
filen <- my_rmd_filename # name of the markdown file without .Rmd suffix
knit(paste0(filen,".Rmd"))
system(paste0("pandoc -s ", paste0(filen,".md"), " -t latex -o ", paste0(filen,".pdf"), " --highlight-style=tango -S"))
# Now find the location on your computer where the PDF file was created:
getwd()
More details about the packages & versions I'm using for this:
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rmarkdown_0.1.4
loaded via a namespace (and not attached):
[1] evaluate_0.5.1 formatR_0.10 knitr_1.5 stringr_0.6.2 tools_3.0.2 yaml_2.1.10
Upvotes: 5