LaTeX function
\documentclass{article}
\begin{document}
\input{folder/file.tex}
\end{document}
\input{folder/file.tex} command in LaTeX fetches the text in the file from the folder. When the main file is run, all the text from file.tex is compiled and included.
Rmd - desired output
I am using R Markdown for my project. I desire to develop and document different topics in different files.
I want to have the following directory structure:
main.Rmd
main_directory
code
file1.Rmd
file2.Rmd
figures
data
read_me
Explored pathways
I have explored the following routes to achieve this.
As suggested in Link 1
sys.source(file = file.path(getwd(), "main_directory",
"code",
"file1.r"))
Here, the code text is not included in the output HTML knit from the Rmd.
- As suggested in Link 2
```{r, child=file.path(getwd(), "main_directory", "code", "file1.Rmd"}
```
It led to the following error:
Error: attempt to use zero-length variable name
Here, the code text is not included in the output HTML knit from the Rmd.
- As suggested in Link 3
```{r}
includeMarkdown(file.path(getwd(), "main_directory", "code", "file1.Rmd"))
```
It also led to the following error:
Error: attempt to use zero-length variable name