I created a R markdown document that takes a report ID number as a parameter and then uses that ID to query a database to pull all the information that goes into the report.
The report uses these libraries: "rmarkdown", "readxl", "dplyr", "Rblpapi", "tidyr", "lubridate", "stringr","knitr", "kableExtra", "RCurl", "XML", "RMySQL" and "webshot"
The report worked fine when I ran it by clicking the knit button in RStudio with a hardcoded report ID#. When I moved to a for loop and calling rmarkdown::render with the Rmd file as a parameter the report will only run once and then throws this error for an add_header_above() header.
! Undefined control sequence.
@sharp ->\makecell
[c]{A title header that spans 5 columns}
If I restart R and run it it will run 1 report again and then fail. I made sure I only load packages once by checking if they are already loaded using (.packages()). I need to make a few dozen of these reports so calling render from the for loop needs to work.
These are the parameters I am passing to the render function:
thisValue = rmarkdown::render("AReport.Rmd",
params = list(reportID = thisID),
output_format = "pdf_document")