package development within positron workspace

When developing packages in Rstudio, i often have two instances of Rstudio open.

a) package project
b) research project, that uses the package

The workflow is something like

  1. make changes to package and build it
  2. switch to research project, restart rstudio, use/test package
  3. switch back to package project and repeat

With Positron i was hoping to avoid this switching and restarting by using workspaces. I create a workspace that includes two folders, one which is the root of my package project, and the other being the research project.

However i can not seem to settle on a good workflow that doesn't involve either moving the order of the folders (to make the upper most in the list the "active" folder and found using here::here()) or constantly using setwd() to switch active folders.

In nearly all of my cases the project folder contains model output that is passed to the package, so i use here::here() to point to the model output when the research project is active. I guess maybe using pak::local_install(root = "hardcoded path from c:"), rather than ctrl+shift+b, would be an option but is there a better way?

Any suggestions on a satisfying workflow?

ps. i will eventually want to include additional packages to co develop in the same workspace

1 Like

I think that Positron's ability to set up a multi-root workspace could really be useful in a situation like this! If I were in this situation, here is what I think I would try:

  • Put the two folders in the workspace, as you described
  • Set up the console to have the working directory set to the analysis folder
  • Use devtools::load_all("relative/path/to/pkg) to load the package into the active R session from wherever it lives

You'd be able to iteratively work on the package and then apply those functions to the code in your analysis folder in this way, with no restarting. You might read more from Jenny on this type of workflow at Multiple R sessions and package development linking · posit-dev/positron · Discussion #6588 · GitHub.

Another approach I might try is to again have both folders in your workspace, but then to set up multiple console sessions as described in Introducing Multiple Console Sessions! · posit-dev/positron · Discussion #6712 · GitHub. I would set up two consoles with the two working directories and switch between them, much like you would switch between RStudio windows before. You would need to restart the analysis console session to get the new version of the installed package that you installed in the other console, but you wouldn't need to restart the whole IDE. The support for multiple console sessions is very new, so if you have feedback for your use case, we would welcome any info you share!

1 Like