The title of this post is pretty self-explanatory, so I will not waste your time reading more into this question.
I have tried to clean the r memory, to restart my laptop, delete the rmarkdown file, make a new file, and then knit to pdf.
The result is still the same: r code output is the different from pdf output.
---
title: "Mockup"
date: "`r format(Sys.time(), '%m/%d/%Y')`"
output:
pdf_document:
fig_caption: yes
fig_crop: no
highlight: zenburn
keep_tex: yes
number_sections: false
toc: yes
toc_depth: 2
header-includes:
- \usepackage{example}
- \usepackage{nicematrix}
- \usepackage{hyperref}
- \usepackage{mathtools}
- \usepackage{amssymb}
- \usepackage{lettrine}
- \usepackage{amsmath}
- \usepackage{yfonts,color}
- \usepackage {titling}
- \usepackage{blkarray}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[R,R]{Mockup}
- \fancyhead[L,L]{Mockup}
- \fancyfoot[C,C]{Mockup}
- \fancyfoot[L,R]{\thepage}
---
```{r setup, include=FALSE, message=FALSE}
library(knitr)
library("DAAG")
library(tree)
library(MASS)
knitr::opts_chunk$set(echo = TRUE, fig.pos= "h", comment = NA, tidy=TRUE, tidy.opts=list(width.cutoff=37))
data(spam7, data ="DAAG")
Spam <- spam7[,c("crl.tot","dollar","bang",
"money","n000","make","yesno")]
Spam$yesno <- as.factor(Spam$yesno)
attach(Spam)
set.seed(1234)
sample_size <- floor(0.8*nrow(Spam))
ind <- sample(seq_len(nrow(Spam)),size = sample_size)
Spam.training <- Spam[ind,]
Spam.test <- Spam[-ind,]
```
```{r,echo = FALSE}
q1.tree <- tree(yesno ~., data = Spam.training)
par(cex = .7)
plot(q1.tree)
text(q1.tree, pretty = 0)
```
R code output (within the Rmarkdown file):
PDF Output:
Any tip on how to fix this?
Thank you!