[R] Why can I reset directory in using setwd on desktop but not on laptop

peter dalgaard pdalgd at gmail.com
Sat Oct 10 13:48:58 CEST 2015


The most likely cause is that permissions and/or ownership of the directory or one of its parents is different between the two machines. It is also thinkable that the ownership of the R process is the problem (in which case it might be an RStudio issue after all).

You likely need a better PC expert than me...

-pd

> On 09 Oct 2015, at 22:33 , WRAY NICHOLAS <nicholas.wray at ntlworld.com> wrote:
> 
> Thanks for your questions Peter
> 
> Both machines are PCs
> 
> In the R routine on my desktop I am changing the place where I store the various csv  files by commands like 
> 
> setwd("C:/Users/Nick/Documents/08915Trent/Outmatstore") where I'm storing particulur matrices (outmats) as csv files.  If I then say
> 
> setwd("C:/Users/Nick/Documents/08915Trent/Resmatstore") to store another kind of matrix (resmats) as csv files elsewhere, the desktop is quite happy with this and lets me change and read.csv and write.csv without problems
> 
> But, having created on my laptop exactly the same path ie C:/Users/Nick/Documents/08915Trent/Outmatstore or Resmatstore etc (that is, I have exactly the same folders nested in the same way on both machines), if I try to change horses in midstream, so to speak, I get an error message 
> 
> Error in setwd("C:/Users/Nick/08915Trent/Resmatstore") : 
>   cannot change working directory
> 
> Not only this, but the laptop will not let me write to any path except one involving C:/Users/Nick etc that is if I try to write to any folder not part of the main administrator's path then it won't let me
> 
> If I do getwd() on either machine before or after the attempt (unsuccessful on laptop) tochange directory I get whichever is the current directory, ie the new one on the desktop and the old one on the laptop... 
> 
> ?
> 
> Thanks, Nick
> 
>> On 09 October 2015 at 20:29 peter dalgaard <pdalgd at gmail.com> wrote:
>> 
>> 
>> 
>> > On 09 Oct 2015, at 17:58 , WRAY NICHOLAS <nicholas.wray at ntlworld.com> wrote:
>> > 
>> > Thanks Sarah I didn't realise that there was a distinction between between
>> > asking about R per se and asking about r-studio... I shall try specifying the
>> > path and see whether that helps Thanks, Nick
>> 
>> The key part of the story is not necessarily Rstudio specific, though:
>> 
>> You said that your laptop "won't allow me to reset the directory by a setwd command".
>> 
>> Now what makes you think that? I can imagine a number of misinterpretations that might lead you there without it actually being true. So:
>> 
>> - Is there an error message? 
>> - What exactly did you type in?
>> - Does the directory actually exist on both machines?
>> - Are we talking about machines with the same architecure? (e.g., is one a PC and the other one a Mac?)
>> - If you do a getwd() before and after the setwd(), what happens?
>> 
>> -pd
>> 
>> > 
>> >> 
>> >> On 09 October 2015 at 16:51 Sarah Goslee <sarah.goslee at gmail.com> wrote:
>> >> 
>> >> 
>> >> Sounds like an RStudio question to me. Someone might be able to help,
>> >> but this mailing list is for R.
>> >> 
>> >> You should also provide sessionInfo() output when asking potentially
>> >> OS-related questions.
>> >> 
>> >> You can always specify path as part of the write.csv() or other output
>> >> command; you don't need to change the working directory necessarily.
>> >> 
>> >> Sarah
>> >> 
>> >> On Fri, Oct 9, 2015 at 11:43 AM, WRAY NICHOLAS
>> >> <nicholas.wray at ntlworld.com> wrote:
>> >>> Hi I am running the same r routine on both my desktop and my laptop, and
>> >>> writing results in the form of csv files into storage folders in the
>> >>> respective
>> >>> users/documents files of both machines My desktop machine allows me to
>> >>> reset
>> >>> the directory in the course of the r programme so that I can write the
>> >>> files
>> >>> into different folders which makes it easier to keep track of what's
>> >>> what,
>> >>> whereas my laptop won't allow me to reset the directory by a setwd
>> >>> command, and
>> >>> I have to set the directory manually using the r studio tabs, so
>> >>> basically on
>> >>> the laptop every results file is going into the same folder, which is
>> >>> not
>> >>> unworkable but not as easy to use later
>> >>> 
>> >>> As far as I know I have the same r studio on both machines. Does anyone
>> >>> out
>> >>> there know a) why I can't use a setwd command on the laptop, and b)is
>> >>> there
>> >>> anything I can do to put this right?
>> >>> 
>> >>> Thanks beforehand, as it were
>> >>> 
>> >>> Nick Wray
>> >> 
>> > [[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.
>> 
>> -- 
>> Peter Dalgaard, Professor,
>> Center for Statistics, Copenhagen Business School
>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>> Phone: (+45)38153501
>> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> >
> 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list