.rproj and command line interfaces

I've started improving reproducibility and useability with R projects and packrat.

However I also prefer to work in R using radian (or just R at command line) and Sublime Text.

Given packrat edits the local .Rprofile to hook into package installation on startup, and I've set the settings in the .Rproj to not save history, load existing data, etc. what do I have to keep in mind when working on the same .rproj with co-authors when they use RStudio by I use sublime text and a terminal?

Sometimes it's hard to tell when some features apply only to Rstudio and others apply to other modes of working in R.

I'm sorry for not directly answering your question, but I would advise you to look at renv which is the successor to packrat

Darn. Okay thank you for the update I will re-do my test project with renv.

This dovetails nicely with the original question.

It seems like renv does not modify the .Rprofile the way packrat did. So when I open an R project, do I need to call renv::init() or does Rstudio do something behind the scenes?

If it does something behind the scenes, how can I ensure the same behavior at the terminal?

renv::init is only used to initialise renv with a project. i.e. first time set up.
next time you work on the project I wouldnt expect you to use renv::init. you could simply put renv::restore() as a line in your script, and it will ensure all needed libraries that has been snapshotted by renv will be loaded as part of your script.
As you work on developing a project adding and removing library dependencies, you manually use renv::snapshot() to record such changes, so that your renv::restores() will succeed.
There are features like renv::activate() to auto load behaviours and things, but I generally don't bother with that.

Thanks. Yes that seems right. However it looks like this should be automated according to the docs

One user (perhaps yourself) should explicitly initialize renv in the project, via renv::init(). This will create the initial renv lockfile, and also write the renv auto-loaders to the project’s .Rprofile and renv/activate.R. These will ensure the right version of renv is downloaded and installed for your collaborators when they start in this project.

When I did renv::init() it didin't modify my local .Rprofile. I think this is a bug. I looked at github to see what the added code should be but couldn't find anything super helpful, though this code seems relevant. Help is appreciated.

EDIT: Removing the .Rprofile and re-running renv::init() fixed the problem. I think I'm all set up.

Thanks!

Here's a better version of my core question

What do I need to put in my .Rprofile so that the following .rproj options are preserved when I start at the command line with R?

Version: 1.0

RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: No

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.