I'm trying to use a forloop to produce multiple reports by feeding an Rmarkdown file through an r script.
Upon running the forloop, I receive the following error, originating from the Rmakrdown file:
Quitting from lines 69-70 (WeeklyReportTemplate.Rmd)
Error in dir.create(dirname(name), recursive = TRUE) :
invalid 'path' argument
Here is the r script:
library("rmarkdown")
library(tidyverse)
library(ggplot2)
install.packages("reprex")
library(reprex)
PennState1 <- read_csv("Baseball/PennState1.csv")
PitcherName = unique(PennState1$Pitcher)
show(PitcherName)
for(PitcherName in PennState1){
rmarkdown::render('/Users/NoahThurm/Desktop/WeeklyReportTemplate.Rmd',
output_file = paste("WeeklyReport_", PitcherName, '_', ".html", sep=''),
output_dir = '/Users/NoahThurm/Desktop')
}
Here are lines 69-70 in the Rmd (error source):
print(VeloPlot)
Which reference the preceding chunk:
I've never used the dir.create() function, and it isn't in my code, is there something going on I'm not accounting for? Any other tips for smoothing out this forloop process would be much appreciated.