This is an ugly hack but add this line to your sourced script: this.dir <- dirname(parent.frame(2)$ofile)
It must be at top level, i.e. not in a function in the script. On Tue, Jan 13, 2009 at 6:53 AM, ppaarrkk <simon_...@yahoo.co.uk> wrote: > > Is it possible for an R script to read a text file, say, from the directory > in which the script is located ? > > I don't think I can use setwd(), because I can't specify the directory. > -- > View this message in context: > http://www.nabble.com/Read-a-text-file-from-a-directory-in-which-an-R-script-finds-itself-tp21434236p21434236.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.