sysuse auto
generate gpm = 1/mpg
summarize price gpm
A second, later code block:
regress price gpm
1. Open Rstudio
2. Click on "Tools" -> "Global Options..." -> "R Markdown".
2. In "Evaluate chunks in directory", select "Project" from the dropdown menu, then click "OK"
1. Create a new Rstudio project
2. Save the previous example as a `.Rmd` file in the root folder.
3. Knit the example; everything goes fine.
4. Now create a subfolder (e.g. `notebooks`), and copy the `.Rmd` file into that subfolder.
5. Knit the version of the `.Rmd` file in the subfolder.
6. The second chunk does not run properly, allegedly because `collectcode=TRUE` fails.
A `profile.do` is created in the subfolder and then deleted. However, it might be the case that Stata "looks for" the `profile.do` in the root directory of the project somehow.
Now:
1. Click on "Tools" -> "Global Options..." -> "R Markdown".
2. In "Evaluate chunks in directory", select "Document" from the dropdown menu, then click "OK"
Repeat step 5; the second chunk now runs properly. My guess is that this issue is related to #12 , and most probably to [this response](https://github.com/Hemken/Statamarkdown/issues/12#issuecomment-731277899). However, I think this is a new use case that may help shed some light into the solution.
Take the following example, adapted from the Statamarkdown handbook:
A first code block:
A second, later code block: