I'm testing out Positron for the first time and looking to streamline my workflow. Specifically, I am trying to create quarto documents that combine R code with Stan models.
The cmdstanr::register_knitr_engine function makes it possible to define Stan-specific chunks that get compiled into a object that is available to all subsequent R chunks. So, I can write something like:
This works great when I compile the full quarto documents I'm building.
Where I'm hitting friction is in interactive editing. When I'm working exclusively with R in Positron, I can trigger a "Run Above" command that will execute all chunks above the current one, making all objects assigned available to the current session.
Obviously, this doesn't happen with Stan chunks, but that causes my code to fail because model isn't available.
Has anyone found a good solution? I can create the session object manually in the console, but that's tedious and prone to error. Is there a better way? Is it possible, perhaps, to tell Positron how to "run" these blocks?
This is an interesting point; thank you for raising it! It looks somewhat to this issue about params:
Do you know how cmdstanr::register_knitr_engine works under the hood? I am not very familiar with the details there, but we would be very happy to work with the cmdstanr folks to find a good path forward.
Thanks for your reply! The issue you link is definitely related conceptually (differences between interactive and build modes).
As far as I understand, cmdstanr::register_knitr_engine just passes a cmdstanr-specific processing command over to knitr. This is a core capacity of knitr itself, which defines different engines for different types of chunks.
...is the |> Run Cell | Run Next Cell | Run Above bit getting added by positron or by the Quarto vscode plugin? Does knitr get involved when these buttons are pushed, or is it all handled in parallel?