0

I am running R 3.5.0 64 bit on my Windows 10 laptop. I can set the Working directory fine for my work space but I am unable to make a permanent change. Each time I reload it, it does not stick.

I changed my Start In file path to the new directory under properties when right clicking the icon.

I have also added setwd() with my file path in the Rprofile.site file

No matter what I do, it continues to revert back to documents when I run getwd() in R when I open it new.

Anyone have any ideas on what I can do to make it stick?

Thanks in advance

Tcanuth
  • 3
  • 3
  • 1
    Are you using it within RStudio? It might be affecting the starting directory, despite your better efforts. – r2evans Jun 29 '18 at 04:20
  • I am not using RStudio. I am using the standard R Client. I have been considering switching over however due to the easier interface I have heard about – Tcanuth Jul 02 '18 at 18:10
  • My answer at https://stackoverflow.com/a/66962964/5114585 & my quick video athttps://youtu.be/hMjzO4bAi70 will help you set a permanent working directory [when not in projects] – Dr Nisha Arora Aug 08 '22 at 03:41

1 Answers1

1

You could go the route of using an .Rprofile which is a way to run scripts / commands on startup. Read about .Rprofile files here in Efficient R Programming

Also, has has been mentioned by @r2evans, if you're using RStudio, there is an option for setting the default working directory. It's under the General section of the Tools -> Global Options menu.

MHammer
  • 1,274
  • 7
  • 12
  • I have already tried adding the commands to the beginning of the Rprofile with no luck. Its almost as if it skips over it entirely. – Tcanuth Jul 02 '18 at 18:10
  • 1
    Odd. An easy way to check that the .Rprofile files are in fact being read in / run is to add something as simple as `print("Hello World")`. When you start up R you should see the results in the console. If not, then you know they're not being properly referred or run .Rprofile files are simply files R sources when it starts up. I know I've used this debugging trick before to check that things were setup properly. – MHammer Jul 02 '18 at 18:44