Error when loading a project using .Rprofile

94 views
Skip to first unread message

HBat

unread,
Oct 17, 2014, 1:51:20 PM10/17/14
to project...@googlegroups.com
Hi I'm using Rstudio and put following .Rprofile file within project folder:

library('ProjectTemplate')
setwd
("SOME FOLDER PATH")
load
.project()

But when I open an Rstudio project I got following error:

Loading project configuration
Error in translate.dcf(config.path) : could not find function "setNames"

At this moment if I write load.project(), the project loads without any problem. 
If I already use "Packrat" in my project and I have following .Rprofile file within project folder:

source("packrat/init.R")

library
('ProjectTemplate')
setwd
("SOME FOLDER PATH")
load
.project()

The project loads without any problem. 
Here is my session info that gives the error above:
> sessionInfo()
R version
3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale
:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached
base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages
:
[1] ProjectTemplate_0.6

loaded via a
namespace (and not attached):
[1] packrat_0.4.1-1 tools_3.1.1    


I don't know the problem is related to ProjectTemplate, but any insight will be welcome.  

kirill...@gmail.com

unread,
Oct 19, 2014, 11:57:16 AM10/19/14
to project...@googlegroups.com
I think the issue is related to the startup behavior documented at https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html :

"Note that when the site and user profile files are sourced only the base package is loaded, so objects in other packages need to be referred to by e.g. utils::dump.frames or after explicitly loading the package concerned."

Probably Packrat loads the relevant packages, so that the error doesn't occur in this context.

This particular issue might go away if you say `library(stats)` in your `.Rprofile`, but loading other packages might be necessary, too.

HBat

unread,
Oct 19, 2014, 12:13:45 PM10/19/14
to project...@googlegroups.com
Yes, I see the problem. "load.project()" uses functions from "stats" and "utils" packages. As you recommended, when I load those packages before running "load.project()", everything worked perfectly:

library(stats)
library
(utils)


library
('ProjectTemplate')
setwd
("SOME FOLDER PATH")
load
.project()

Thanks alot. 

Reply all
Reply to author
Forward
0 new messages