Re: [R] How do I tell it which directory to use?

From: Adaikalavan Ramasamy <ramasamy_at_cancer.org.uk>
Date: Wed 22 Feb 2006 - 23:23:42 EST

I think the idea of defining dir1 and dir2 is a good one. If you want to simplify life even further, you can put these into files that get initialised when R starts. See help(Startup) for details.

Regards, Adai

On Wed, 2006-02-22 at 16:54 +1100, Augusto.Sanabria@ga.gov.au wrote:
> Tom,
>
> You can define your working directory by using:
>
> setwd("C:\Documents and Settings\Tom\My Documents\qpaper7\R Project Started
> 19 Dec 05")
>
> check that your file is there:
> list.files()
>
> and then use:
>
> source("myFile.txt")
>
> the machine should load "myFile"
>
> You can go to another directory:
> setwd("anotherdir")
>
> and repeat the procedure.
>
> Or even better if you define a number of directories in an external file:
>
> dir1 <- c(C:\Documents and Settings\Tom\My Documents\qpaper7\")
> dir2 <- c(C:\Documents and Settings\Tom\My Documents\")
>
> and after loading the file at the beginning of the sesion you can use:
>
> setwd("dir1") etc.
>
> Is it of any help to you?
>
> Cheers,
>
> Augusto
>
>
> --------------------------------------------
> Augusto Sanabria. MSc, PhD.
> Mathematical Modeller
> Risk Research Group
> Geospatial & Earth Monitoring Division
> Geoscience Australia (www.ga.gov.au)
> Cnr. Jerrabomberra Av. & Hindmarsh Dr.
> Symonston ACT 2609
> Ph. (02) 6249-9155
>
>
> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Thomas L Jones
> Sent: Wednesday, 22 February 2006 4:31 PM
> To: R-project help
> Subject: [R] How do I tell it which directory to use?
>
>
> >From Tom:
>
> In R 2.2.0 under Windows, I want to be able to give it a filename such
> as "myFile.txt" without the quotes. But actually I mean:
>
> C:\Documents and Settings\Tom\My Documents\qpaper7\R Project Started
> 19 Dec 05\myFile.txt
>
> If I were to repeat this each time, my computer would get all bored
> and cranky and start to drop bits (only a joke, of course). I think I
> want to set the Home directory or the working directory or some
> directory or other to the above directory. I may or may not want to
> set some environmental variables.
>
> R 2.2.0; working directly from the console and copying and pasting
> code which I want to test into the console. Windows XP Home Edition.
> Administrator privileges are enabled. A curve ball: There are two
> accounts, "Tom" and "Jones;" the data are stored under "Tom," whereas
> the computation is being done under the "Jones" account. I won't bore
> you with the details of why I am doing this.
>
> I was able to call Sys.getenv ("R_USER") and get the home directory.
>
> I am a newbie to R and not familiar with the terminology.
>
> Tom
> Thomas L. Jones, Ph.D., Computer Science
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Feb 22 23:29:39 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:39 EST