Different RProfile for a project
Is it possible to have R load from a particular RProfile when a project opens (specific to that project)? I assumed this would happen, so I made a new RProfile and put it in the working directory for that project, but it is just loading my default RProfile. I'd like to do this to load specific functions and packages when I open the project. Maybe there is a different way to accomplish this?
Thanks,
Joel
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Josh Paulson on 01 May, 2012 02:55 PM
Joel,
This should be working if you put a different .Rprofile in the root directory of each project. I just tested it and got it working fine. For example if you start a new project in
~/Desktop/foothen you run the following code:This will open a new document called .Rprofile and I just put the following commands in to test (note the blank line at the end):
After that, you can switch projects from inside RStudio and it will load the correct .Rprofile. Let me know if you are able to get this working. Just make sure to save it in the root directory of the project (where the foo.Rproj file is as well.).
Josh
3 Posted by Joel Martin on 01 May, 2012 03:00 PM
I have a .Rprofile in the project directory, but it doesn't seem to be
loading from it. Do I need to create it with the commands you list below,
or should it recognize any file called .Rprofile in the working directory
for the project?
Support Staff 4 Posted by Josh Paulson on 01 May, 2012 05:57 PM
Joel,
You don't need to use this exact command (it just opens up the file if it exists or creates a new one). Are you naming the file such as
foo.Rprofileor is it just called.Rprofile? This would lead to it loading the default.Rprofileif you named it.Josh
5 Posted by Joel Martin on 01 May, 2012 06:25 PM
Well, I'm not sure why but when I created the .Rprofile using the step
file.edit() command you gave me, it now works. File looks exactly the same
as far as I can tell, but I must have done something wrong with it. Thanks
for your help.
Support Staff 6 Posted by Josh Paulson on 01 May, 2012 06:30 PM
Joel,
If you were using notepad or another application it might have saved it as a different file type (text file or something else). In this case it could have added a hidden extension. Either way, glad that you got this working.
Josh
Josh Paulson closed this discussion on 01 May, 2012 06:30 PM.