I am new to R and have been trying to write my project report in R markdown. However I am facing issues. I tried implementing solutions present on stack overflow as well as other websites, but I have not been able to make progress.
Details:
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
RStudio Version 0.99.441 – © 2009-2015
Mac OS X Yosemite version 10.10.5
Installed pandoc 1.15.0.6 https://github.com/jgm/pandoc/releases/tag/1.15.0.6
The MacTeX-2015 Distribution from http://tug.org/mactex/
mactex-20150613
Under Global options I have weave Rnw files using knitr, Typeset LaTeX into PDF using XeLaTex, have deselected clean auxiliary output after compile.
I get the following error:
output file: 07.Random_Forest.knit.md
/usr/local/bin/pandoc 07.Random_Forest.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output 07.Random_Forest.pdf --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/latex/default-1.14.tex --highlight-style tango --latex-engine /Library/TeX/texbin/pdflatex ! Undefined control sequence. l.921 {\centering \includegraphics
pandoc: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 Execution halted
Part of my R markdown code is attached for reference:
---
title: "Decision Trees and Random Forest"
paper: a4paper
fontsize: 12pt
geometry:
- tmargin=2cm
- bmargin=2cm
- lmargin=3cm
- rmargin=3cm
documentclass: report
classoption: twoside, bindingoffset=1cm
linkcolor: blue
author: "Chaitanya Jagtap"
date: "15 September 2015"
output: pdf_document
---
opts_chunk$set(echo=FALSE, warning=FALSE, message=FALSE, error=FALSE, collapse=TRUE, tidy=TRUE, highlight=TRUE, comment='')
opts_knit$set(progress=TRUE, verbose=TRUE)
```{r include=TRUE}
library(extrafont)
loadfonts()
library(SDMTools)
library(caTools)
library(randomForest)
library(rpart)
library(rattle)
library(rpart.plot)
library(RColorBrewer)
library(partykit)
library(rmarkdown)
library(geometry)
library(knitr)
library(highr)
library(xtable)
set.seed(211)
fonttable()
options(digits=4)
par(cex=0.9,cex.axis=1,cex.lab=1,cex.main=1.2,cex.sub=1,
font=1,font.axis=1,font.lab=2,font.main=2,font.sub=1,
pin=c(4,3), mai=c(1, 1, 1, .2), oma=c(0.2,0.2,2,0.2), mgp = c(3, 1, 0), adj=0.5,
las=0, xaxs="i", yaxs="i",
col.lab = "firebrick4", col.main="deepskyblue4", col.sub="royalblue", lab=c(10,10,7),
lwd=2,family="Times New Roman", ps=12)
setwd("/Users/Urmila/Desktop/Chaitanya/Study/001_Great Lakes/001_Capstone/002_Give_me_some_credit/")
load("capstone_df_train.RData")
load("capstone_df_test.RData")
xyvar <- c( "GB", "Age_woe", "num_30_59_dpd_woe", "num_60_89_dpd_woe", "num_90_dpd_woe",
"num_open_trades_woe", "num_RE_trades_woe", "Rev_Util_unsec_woe", "Debt_Ratio_woe",
"MI_num_depend_woe")
xvar <- c("Age_woe", "num_30_59_dpd_woe", "num_60_89_dpd_woe", "num_90_dpd_woe",
"num_open_trades_woe", "num_RE_trades_woe", "Rev_Util_unsec_woe", "Debt_Ratio_woe",
"MI_num_depend_woe")
capstone_df_train_xyvar <- capstone_df_train[xyvar]
capstone_df_test_xyvar <- capstone_df_test[xyvar]
weight <- ifelse(capstone_df_train_xyvar$GB == 0,1,12)
dtree_train <- rpart(GB ~ ., data=capstone_df_train_xyvar,
method="class", parms=list(split="information"),
minsplit = 1000, minbucket = 500, cp=-1,
weights = weight)
```
```{r include = TRUE}
dtree_train$cptable
```
```{r include=TRUE, fig.align='center', fig.cap="Plot of cross-validated error against complexity parameter cp"}
plotcp(dtree_train, minline = TRUE, lty=2, col = "firebrick", upper = "size")
mtext("Plot of cross-validated error against complexity parameter cp", side=3, cex=1.1,
line=0.6, col = "dodgerblue4", outer=TRUE)
box("plot", col="blue", lty = "solid")
box("figure", col="forestgreen", lty = "solid")
```
Thank you for your time and help.
Chaitanya