Skip to content
Prev 22372 / 398502 Next

filename of source file

If you use the chdir argument to source(), this will tell your .r file to
work in that directory (including writing output to files). For example,
if you have a file called test.r in c:/tmp that contains the commands
        my.test <- sample(1:5, 100, replace=TRUE)
        write.table(my.test, "test.out")
you can call it using
        > source("c:/temp/test.r", chdir=TRUE)
after which there will be a file in c:/temp called test.out.

Does this achieve what you want?


Regards,

Andrew C. Ward

CAPE Centre,
The University of Queensland
Brisbane Qld 4072 Australia
andreww at cheque.uq.edu.au

----- Original Message -----
From: David Richmond <daver969 at mac.com>
To: Andrew C. Ward <andreww at cheque.uq.edu.au>
Cc: <r-help at hypatia.math.ethz.ch>
Sent: Monday, August 05, 2002 3:25 PM
Subject: Re: [R] filename of source file
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._