0

So I decided to convert my html R markdown file to a pdf knitr and I noticed that half my code output won't show. I replicated a small example here:

---
title: "Test"
author: "Brandon Morgan"
date: "1/19/2021"
output: 
  pdf_document:
    df_print: paged
    fig_caption: yes
    fig_height: 6
    fig_width: 7
    highlight: tango
    toc: yes
    toc_depth: 4
html_document: 
    code_folding: hide
    csl: biomed-central.csl
    fig_caption: yes
    fig_height: 6
    number_sections: yes
    theme: sandstone
    toc: yes
    toc_float: yes
---


# TEST

## Data

```{r}
data = iris
head(data)
```

Here's my html knitr output:

enter image description here

Here's my pdf knitr output:

enter image description here

Notice how head(data) does not show for pdf output

notMyName
  • 690
  • 2
  • 6
  • 17

1 Answers1

1

quick fix: remove df_print: paged. I can't tell you why it would not produce the result you want at the moment.

---
title: "Test"
author: "Brandon Morgan"
date: "1/19/2021"
output: 
  pdf_document:
    fig_caption: yes
    fig_height: 6
    fig_width: 7
    toc: yes
    toc_depth: 4
  html_document: 
    code_folding: hide
    csl: biomed-central.csl
    fig_caption: yes
    fig_height: 6
    number_sections: yes
    theme: sandstone
    toc: yes
    toc_float: yes
---


# TEST

## Data

```{r echo=FALSE, results=TRUE}
data = iris
head(data)
```
randomchars42
  • 335
  • 1
  • 8
  • 1
    I did that and got the error: `Error: Functions that produce HTML output found in document targeting latex output` in my main Rmd document. Found this: https://stackoverflow.com/questions/42543206/r-markdown-compile-error, just had to include `always_allow_html: true` to the bottom and it worked – notMyName Jan 19 '21 at 17:32
  • @notMyName interesting, thanks for sharing! – randomchars42 Jan 19 '21 at 17:55