Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collectcode=TRUE only works for Rmarkdown documents in the root folder of the project (when chunks are set to evaluate in the root folder) #17

Open
DaniMori opened this issue May 5, 2021 · 0 comments

Comments

@DaniMori
Copy link

DaniMori commented May 5, 2021

Take the following example, adapted from the Statamarkdown handbook:

---
title: "R Notebook"
output:
  html_document:
    df_print: paged
---

```{r, include=FALSE}
library(Statamarkdown)
```


A first code block:

```{stata first-Stata, collectcode=TRUE} 
sysuse auto
generate gpm = 1/mpg
summarize price gpm
```

A second, later code block:

```{stata second-Stata} 
regress price gpm
```
  1. Open Rstudio
  2. Click on "Tools" -> "Global Options..." -> "R Markdown".
  3. In "Evaluate chunks in directory", select "Project" from the dropdown menu, then click "OK"
  4. Create a new Rstudio project
  5. Save the previous example as a .Rmd file in the root folder.
  6. Knit the example; everything goes fine.
  7. Now create a subfolder (e.g. notebooks), and copy the .Rmd file into that subfolder.
  8. Knit the version of the .Rmd file in the subfolder.
  9. 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. However, I think this is a new use case that may help shed some light into the solution.

@DaniMori DaniMori changed the title collectcode=TRUE only works for Rmarkdown documents in the root folder of the project (when chunks are set to evaluate in the root folder) collectcode=TRUE only works for Rmarkdown documents in the root folder of the project (when chunks are set to evaluate in the root folder) May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant