0

I'd like to create a report, but my report need to be start with a logo. In my example, I try to do :

Here is the .rmd file (say, cylinder.rmd)

---
```{r echo=FALSE, out.width = "30%", fig.align = "center"}
knitr::include_graphics("R_logo.png")
```
title: "cylinder_report"
author: "author_name"
date: "2023-01-25"
output: pdf_document
params:
  cylinder: 0
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
df = mtcars
```


## Cylinder `r params$cylinder`
```{r output, echo=FALSE}
knitr::kable(df[df$cyl == params$cylinder,])
```

And my separated file is:

library(knitr)
library (rmarkdown)
data(mtcars)
cyls = unique(mtcars$cyl)
for(cyl in cyls) {
  rmarkdown::render(
    input = "cylinder.Rmd",
    output_file = paste0("cylinder_report_", cyl),
    params = list(cylinder = cyl)
  )
}
#

This code doesn't work, but for better comprehension my desirable output must to be:

report1

Please any help with it?

Leprechault
  • 1,531
  • 12
  • 28
  • 1
    Have you tried something in [this](https://stackoverflow.com/questions/27982052/insert-a-logo-in-upper-right-corner-of-r-markdown-pdf-document) direction? – Julian Jan 26 '23 at 12:21

1 Answers1

1

The solution was find in: https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html

The .Rmd needs to be:

---
title: "cylinder_report"
author: "author_name"
date: "2023-01-25"
output: pdf_document
params:
  cylinder: 0
header-includes:
  - \usepackage{titling}
  - \pretitle{\begin{center}
    \includegraphics[width=2in,height=2in]{R_logo.png}\LARGE\\}
  - \posttitle{\end{center}}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
df = mtcars
```


## Cylinder `r params$cylinder`
```{r output, echo=FALSE}
knitr::kable(df[df$cyl == params$cylinder,])
```
Leprechault
  • 1,531
  • 12
  • 28