I working on writing a quantitative finance book using R-Markdown in Rstudio with Knitr interested in produce a dynamic pdf document, but maybe I´m trying something out of my abilities given all the time and problems I´ve faced in all new conversion I try after inserting a new content like a graph, table and/or figure...probably RMarkdown with all other complexities behind the scene like Knitr, Pandoc, MIKTEX is not for a "first-time" users like me, although I already have familiarity with R and Rstudio. But my also first perception is that things are not so tied between all these elements and lots of small adjustments are required which restricts the use for people outside the program language domains.
The content I´m going to publish is really wide to place here, and I don´t expect any kind of "silver bullet" to solve my current and new futures problems to come with the next "Knitr´ing" to do, but maybe you as experts you are may have a kind of "recipe" to workaround the annoying "pandoc.exe: Error producing PDF from TeX source Erro: pandoc document conversion failed with error 43" message I´ve received frequently.
Today my RMarkdown has 2,200 rows with dozens of chunks basically involving data reshaping, tables and graphs generations. Below I´m pasting the way I´m defining my YAML preamble definitions.
---
title: "My book"
author: "Me"
date: "Wednesday, July 31th, 2015"
documentclass: book
fontsize: 10pt
classoption:
b5paper
header-includes:
- \usepackage{tcolorbox}
- \usepackage{longtable}
- \usepackage{amsmath}
geometry:
- tmargin=2cm
- bmargin=2cm
- lmargin=2cm
- rmargin=2cm
output:
pdf_document:
fig_caption: yes
highlight: kate
latex_engine: lualatex
number_sections: yes
toc: yes
toc_depth: 3
---
The R packages being used so that you have an idea about the things I can be doing.
``` {r eval=TRUE, echo=FALSE, message=FALSE, warning=FALSE}
require("pander")
require("knitr")
require("kfigr")
require("rmarkdown")
require("markdown")
require("yaml")
require("xtable")
require("RColorBrewer")
require("graphics")
require("lubridate")
require("data.table")
require("xts")
require("reshape2")
require("ggplot2")
require("scales")
require("plot3D")
require("coefplot")
require("dplyr")
```
My environment:
Rstudio: Version 0.99.482
Pandoc 1.13.2
Knitr version 1.11
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252
[2] LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
loaded via a namespace (and not attached):
[1] htmltools_0.2.6 tools_3.2.0 yaml_2.1.13
[4] rmarkdown_0.7 digest_0.6.8
The last "stranding" involves the following chunk:
```{r X11,anchor="Graph", results='asis',eval=TRUE, echo=FALSE, message=FALSE, warning=FALSE,cache=TRUE,fig.cap="Graph Bar"}
require(data.table)
require(reshape2)
require(ggplot2)
require(scales)
file21<-file.path("C:/Users",username,"OneDrive/Git",folder,"file21.csv")
file<-read.csv(file21,sep=";")
file[,7]<-as.numeric(as.character(file[,7]))
filep[is.na(file)] <- 0.000
df<-melt(file, id.vars=c("Year"))
df$value<-as.numeric(as.character(df$value))
ggplot(df, aes(x=Year, fill = variable,y = value)) +
geom_bar(position = "fill",stat = "identity",color="gray")+
scale_y_continuous(labels = percent_format()) +
theme_classic() +
theme(plot.title=element_text(size=12),legend.position="top",legend.title = element_blank()) + scale_fill_brewer(palette="RdGY") +
geom_text(aes(label=percent(value)), vjust=1,colour="black", position= position_stack(0.9), size=2.5)
```
Just wondering if by looking at these information you could help me to find way to succeed in the pdf document creation escaping of the error number "43"
Many thanks in advance.
Fabio