[R] Looking up the directory a file is located in

jim holtman jholtman at gmail.com
Wed Nov 17 23:52:02 CET 2010


What do you expect it to look up?  How do you want to specify the
directory?  Is it supposed to search through some sequence or use ESP?

On Wed, Nov 17, 2010 at 4:08 PM, Cliff Clive <cliffclive at gmail.com> wrote:
>
> Hello everyone,
>
> This should be an easy question, I think.
>
> I'd like to write a command in a program to set the working directory to
> whatever directory the file is currently stored in.  Suppose I have a file
> called "myRscript.r", and it's stored in "C:\Rprojects\myRscript.r", and it
> references other R scripts and data files in the same directory.
>
> If I enter the command
>
>> setwd("C:/Rprojects")
>
> I can then access all the files I need without typing the path.
>
> But suppose I want to move all of those files into another folder, say,
> "C:\NewFolder".  And suppose I might do this fairly often, or make copies of
> the script in several folders.  Is there a command that looks something like
> this:
>
>> setwd( <look up current directory> )
>
> that will work no matter where I move my project, without having to go in
> and re-type the new directory path?
>
>
> Thanks in advance,
>
> Cliff
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Looking-up-the-directory-a-file-is-located-in-tp3047649p3047649.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list