Manuel
Manuel

Reputation: 265

Makefile with packrat package

I am using the packrat package for my project the first time, and I want to use a Makefile to run specific scripts in a specific order for different targets. However. I organized my file like this:

When I run R CMD BATCH someRfile.R from within the Makefile, R is not using the packrat libs, but the default user libs, which is not what I want. Is there any way to force all R processes startet in any subdir of the packrat dir, to use only the packrat libs?!

Thank you!

Upvotes: 1

Views: 191

Answers (2)

Sam Abbott
Sam Abbott

Reputation: 466

Just had this issue - the following fixed it.

Add an .Rprofile to each subdirectory (and sub-subdirectory etc.) containing the following,

source("../.Rprofile", chdir = TRUE)

From the packrat docs

Upvotes: 1

Benjamin Christoffersen
Benjamin Christoffersen

Reputation: 4841

I guess you have to include source("packrat/init.R") at the very start of someRfile.R as in your .Rprofile file in your project folder.

I assume that you use R studio in the above comment.

Upvotes: 1

Related Questions