I'm beginner in Rstudio IDE.
It's been several weeks now that I research how can I input metadata (to yaml front matter) in rmardown file which from r file or r script.
To resume, I made template.tex with my own pandoc variable then, in r script, I wrote some sqlQuery and in the end I use render("file.Rmd").
To finish my file.Rmd look likes :
It looks like you might be looking for rmarkdown parameters. They let you specify (surprisingly) parameters to a report/rmarkdown document, such as a data set/SQL query to use for the rest of the report.
The indentation of the output in my Rmd are correct It's on RStudio community that this is badly displayed... Otherwise I totally respect the identation.
I tryed knit with parameters but it's always the same things. RStudio returns the same warnings... And in parameters RStudio does not apply my R script.
In my global environment I have every correctly data but RStudio returns this warnings :
! LaTeX Error: File `.cls' not found.
! Emergency stop.
<read *>
Error: Failed to compile technical_file.tex. See technical_file.log for more info.
\documentclass[a4paper,landscape]{$online$} %macro is in my .cls
\data1{$if(data1)$$data1$$endif$}
\data1{$if(data2)$$data2$$endif$}
\begin{document}
\makefile
\end{document}
Error in eval(parse_only(code), envir = envir): objet 'data1' not found Calls: <Anonymous> ... inline_exec -> hook_eval -> withVisible -> eval -> eval Execution stopped
It seems to me that when I make a render() it doesn't detect my variables in the GlobalEnvironment... And I tried to make save(data1, file="data1.RData") and in yaml front matter, metadata1: "` r load("data1.RData")`" but it returns an error message with yaml::yaml.load(...)
You're right that render() won't detect variables in the Global Environment, iirc render() runs the document in a fresh R session, so your current workflow won't work.
I'm not clear on exactly what your main aim is here, but I'd recommend reading through the parameters section of the Rmd book here to get some more details.
What is the purpose of metadata1/metadata2? Are you trying to create the same report for two sets of metadata, or do something else?
My goal is to generate my reports automatically because my basic work is located on a database that I handle every day. So the principle is that after that I don't touch the codes anymore.
I am quite a perfectionist so I have my own Latex template and its presentation is very graphic.
So how can I access my .GlobalEnvir ? I tried with knit(), knit2pdf() and many others, the result remains the same.