Johannes W. Dietrich wrote: > > At 19:29 Uhr -0400 12.05.2010, Gabor Grothendieck wrote: >>If you are running the file via source("myfile.R") then just put this >>in the file: >> >>this.dir <- dirname(sys.frame(1)$ofile) >> >>This is a bit fragile since changes to the internals of source could >>break it but it does currently work. > > Great, this is the solution. It works if the script has been saved > before running. > > Thank you, > > J. W. D. >
I *strongly* suggest you consider packages if you are sharing collections of R functions and scripts with other people. Compared to other programming languages I have used, R makes it dead simple to create packages. All you really need to get started is: ?package.skeleton() That command creates a set of folders whose structure is pretty self explanatory: package.skeleton( 'myPackage' ) Creates the beginnings of a package structure: myPackage/ R/ => Files containing your custom R functions go in here data/ => Data sets go in here man/ => For documentation files inst/ => Everything else such as scripts and config files The "Writing R Extensions Manual" can help you fill in the rest of the blanks. The bottom line is that creating a package cost a minimal investment of extra time and pays back huge dividends if the collection of scripts and data files you are sharing gets complex or you people ask you to document the software that they are starting to depend on. -Charlie ----- Charlie Sharpsteen Undergraduate-- Environmental Resources Engineering Humboldt State University -- View this message in context: http://r.789695.n4.nabble.com/Path-to-R-script-tp2196648p2216184.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.