[R] filename of source file

David Richmond daver969 at mac.com
Mon Aug 5 07:25:15 CEST 2002


Yes, source refers to the use of the source() function. Suppose I invoke 
a file like so:

source("/path/name/filename.r")

I want to insert a command in filename.r like so:

fullpath <- magic_command()

such that fullpath is now "/path/name/filename.r"

In other words, I want filename.r to be able to figure out where it is, 
regardless of where I put it, so that it can save all its output in the 
same directory.

dave r


On Sunday, August 4, 2002, at 10:09 PM, Andrew C. Ward wrote:

> Dave,
>
> You may like to give an example usage since I'm not 100% sure what you 
> wish
> to achieve. Does "current source" refer to the source() command, to
> read.table(),
> or to something else?
>
> You may like to create a variable save.dir in your .Rprofile or in your
> working
> session that points to the folder you want everything saved in.
>
> 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: <r-help at stat.math.ethz.ch>
> Sent: Monday, August 05, 2002 12:31 PM
> Subject: [R] filename of source file
>
>
>> Hi
>> Is there a command which will return the complete pathname of the
>> file from which the current source is being read? I want something 
>> which
>> can be inserted into any .r file and it will be able to ascertain
>> exactly where it is, so that it can save data to the same directory, no
>> matter where it is, regardless of what the current working directory 
>> is.
>>
>> Dave Richmond
>> daver969 at mac.com
>> ------------------------------------------------------
>> "It works on a complex scientific principle
>> known as pot luck." - The Doctor
>>
>> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
>> -.
> -.-.-
>> 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
>>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list