I have a dataset that looks like this
ID|Electronic|Nations
1 Panasonic Japan
2 Yamaha Japan
3 Sony Japan
4 Apple USA
5 Microsoft USA
6 Samsung Korea
From the dataset there should be 3 PDFs with corresponding plots and adjusted title based on the unique values from column "Nations". As a test we can add the line of code below to see if the pdf is dynamic.
table(df$Electronic)
Is this possible?
Update**
---
title: "Electronics"
author: "JW"
date: "8/10/2021"
output:
pdf_document: default
html_document: default
params:
Nations= Japan
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
tinytex::install_tinytex()
library(tidyverse)
library(knitr)
df<-tibble(ID=c(1,2,3,4,5,6), Electronic=c("Panasonic","Yamaha","Sony","Apple","Microsoft","Samsung"),
Nations=c("Japan","Japan","Japan","USA","USA","Korea"))
lst1 <- split(df, df$Nations)
render_one <- function(Nations) {
# assuming the output format of input.Rmd is PDF
rmarkdown::render(
'input.Rmd',
output_file = paste0(Nations, '.pdf'),
params = list(Nations=lst1),
envir = parent.frame()
)
}
for (Nations in lst1) {
render_one(taxnum)
}
#For test
table(df$Nations)
table(df$Nations)
Error in abs_path(input) : The file 'input.Rmd' does not exist.
Calls: <Anonymous> ... render_one -> <Anonymous> -> setwd -> dirname ->
abs_path
Execution halted
No LaTeX installation detected (LaTeX is required to create PDF output).
You should install a LaTeX distribution for your platform:
https://www.latex-project.org/get/
If you are not sure, you may install TinyTeX in R:
tinytex::install_tinytex()
Otherwise consider MiKTeX on Windows - http://miktex.org
MacTeX on macOS - https://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome _strongly_ recommended)
Linux: Use system package manager
Note that I ran tinytex::install_tinytex() and that when i run an individual report it works when doing a knit.