On Tue, 28 Feb 2006, Greg Tarpinian wrote: > Thank you both for your helpful suggestions. My ignorance of R prevents me > from understanding exactly how to > > "...run from a shortcut, appending DATADIR=J:/foo/bar to the > command line"
See the rw-FAQ for more details. > but I assume that Appendix C of "S Programming" will help me there -- I was > unaware of this material when I posted my question. I was able to success- > fully use the following: > > > Sys.putenv("R_DATADIR"="Z:/.../raw") > > Sys.getenv("R_DATADIR") > R_DATADIR > "Z:/.../raw" > > file.path(Sys.getenv("R_DATADIR"), "RAWDATA.xls") > [1] "Z:/.../raw/RAWDATA.xls" > > Using this type of code, I should be able to "point" R at data and output > directories. In my industry, programmers are required to save their SAS > log files for auditing purposes, and knowing that R has similar capabilities > is very helpful. > > Again, thanks for your help. Kind regards, > > > Greg > > > > > --- Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > >> On Tue, 28 Feb 2006, Uwe Ligges wrote: >> >>> >>> >>> On Mon, 27 Feb 2006, Greg Tarpinian wrote: >>> >>>> BACKGROUND: >>>> I use SAS on a daily basis and one of its most powerful features in a >>>> production environment is the use of LIBNAME and FILEREF statements, e.g.: >>>> >>>> >>>> PROC PRINTTO LOG = "&LOGDIR.\data processing.log" NEW; >>>> RUN; >>>> PROC IMPORT >>>> DATAFILE= "&DATADIR.\blah.xls" >>>> OUT = TEMP >>>> DBMS = EXCEL REPLACE; >>>> SHEET = "Sheet1"; >>>> GETNAMES = YES; >>>> RUN; >>>> >>>> >>>> Properly setting up SAS Shortcuts in the WinXP environment, or (say) >>>> the UNIX equivalent of batch files in the UNIX environment will cause >>>> SAS to autoexecute (say) an INIT.SAS file that automatically assigns >>>> the LOGDIR and DATADIR macro variables used above. This is extremely >>>> convenient because it makes the SAS code more portable from project to >>>> project. >>>> >>>> >>>> MY QUESTION: >>>> Is it possible to use this kind of relative file and directory referencing >>>> from within R? >>> >>> Perhaps you are looking for ?setwd >> >> Another idea is to use environment variables. So if in an R function I >> have >> >> xls_file <- file.path(Sys.getenv("DATADIR"), "blah.xls") >> >> I can R run from a shortcut, appending DATADIR=J:/foo/bar to the command >> line. >> >> -- >> Brian D. Ripley, [EMAIL PROTECTED] >> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ >> University of Oxford, Tel: +44 1865 272861 (self) >> 1 South Parks Road, +44 1865 272866 (PA) >> Oxford OX1 3TG, UK Fax: +44 1865 272595 >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html