Greetings,
Firstly, I'd hope this is the correct e-mail address to ask about specific
problems refering to problems with R. If it isn't, I kindly ask of you to
re-direct me to the correct contact person.
So, the thing with my version of R (I'm using RStudio for R x64 3.3.0 in,
currently, Windows 7) is, that I'm able to set the working directory
temporary (through using setwd() function), but once I try to set it
permanently (through "Session -> Set Working Directory -> Choose
Directory..."), this error appears: Error in setwd("~/...") :
cannot change
working directory.
As I've seen online on certain forums, the problem, supposedly, is that R
in Windows is unable to recognize the ~ sign. But without it, I'm unable to
set the working directory for more than a session.
I'd hope you have a possible answer to this error.
Thank you for your time and for reading this long e-mail and I hope you
have a fine day, An?e D.
[[alternative HTML version deleted]]
Hi Anze,
I'm not sure that this will work on Windows, but you can create a
function named ".First" (note the leading period) with something like
this:
.First<-function() setwd("C:/Users/anze")
To do this, start a session, enter the above line and then quit the
session, saving the current workspace. When you start R again, it
should change to that working directory. Of course you should make
sure what your home directory is.
Jim
On Sat, Oct 15, 2016 at 5:52 AM, An?e Dejak <anze.dejak at gmail.com>
wrote:> Greetings,
>
> Firstly, I'd hope this is the correct e-mail address to ask about
specific
> problems refering to problems with R. If it isn't, I kindly ask of you
to
> re-direct me to the correct contact person.
>
> So, the thing with my version of R (I'm using RStudio for R x64 3.3.0
in,
> currently, Windows 7) is, that I'm able to set the working directory
> temporary (through using setwd() function), but once I try to set it
> permanently (through "Session -> Set Working Directory -> Choose
> Directory..."), this error appears: Error in setwd("~/...")
: cannot change
> working directory.
>
> As I've seen online on certain forums, the problem, supposedly, is that
R
> in Windows is unable to recognize the ~ sign. But without it, I'm
unable to
> set the working directory for more than a session.
>
> I'd hope you have a possible answer to this error.
>
> Thank you for your time and for reading this long e-mail and I hope you
> have a fine day, An?e D.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
On 14/10/2016 2:52 PM, An?e Dejak wrote:> Greetings, > > Firstly, I'd hope this is the correct e-mail address to ask about specific > problems refering to problems with R. If it isn't, I kindly ask of you to > re-direct me to the correct contact person. > > So, the thing with my version of R (I'm using RStudio for R x64 3.3.0 in, > currently, Windows 7) is, that I'm able to set the working directory > temporary (through using setwd() function), but once I try to set it > permanently (through "Session -> Set Working Directory -> Choose > Directory..."), this error appears: Error in setwd("~/...") : cannot change > working directory. > > As I've seen online on certain forums, the problem, supposedly, is that R > in Windows is unable to recognize the ~ sign. But without it, I'm unable to > set the working directory for more than a session.That explanation is incorrect. R in Windows simulates a Unix shell interpretation of ~ . See ?path.expand for an explanation, and run path.expand("~") to see how it is currently being expanded for you. However, the fact that R interprets ~ doesn't mean it is always possible to use setwd() to go there. It's also possible that RStudio has a bug, and is trying to change to a nonexistent directory before displaying choices to you, assuming you're getting the error before being offered the dialog to pick a directory. If that's the case, you might be able to avoid the problem by asking R to make the change: setwd(choose.dir()) or setwd("a/specific/directory") Duncan Murdoch