[R] the name of the current running script.r

Henrique Dallazuanna wwwhsd at gmail.com
Thu Aug 14 15:42:00 CEST 2008


maybe you can do something about like this:

#height.r script beg
SourceFileDir <- "f:/documents/data & fits/THz Imaging Lab/r scripts"
SourceFileName <- "height.r"
source(file.path(SourceFileDir, SourceFileName))
# height.r script end


savehistory()
FileNameSourced <- gsub("source\\(|\\)|\"", "",
tail(head(readLines(".Rhistory") , -1), 1))

On Thu, Aug 14, 2008 at 10:03 AM, Zroutik Zroutik <zroutik at gmail.com> wrote:
> Dear R users,
>
> is there a hack how to get the filename of the current script.r sourced/ran?
>
> My issue: I have a couple of scripts which were optimised and are placed in
> tens of directories. (I have a height.r script in 30 directories, a lines.r
> script in 25 directories and another flow.r script in 54 directories,
> growing). The script runs in the directory and does its job: sources data
> and creates plots. From time to time I realise there is a possible update to
> a script and then I have to copy the new version over all my directories to
> overwrite the old scripts. So, it is better to have a script height.r:
>
> # height.r script beg
> SourceFileDir <- "f:/documents/data & fits/THz Imaging Lab/r scripts"
> SourceFileName <- "height.r"
> source(file.path(SourceFileDir, SourceFileName))
> # height.r script end
>
> placed in every directory and when running it, it sources the one and only
> script height.r (this is the core script file) from a fix place.
>
> But, I need again three/more other scripts depending on the name (thus type)
> of the script (note the third line of the script above). Anything which
> would give me the name of the script currenlty running or last sourced or
> anything.
>  I know getwd() gives me the working dir, but I need the working script
> name.
>
> Any help appriciated. Thank you very much in advance.
> Milan
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list