The command line variable setting S_PROJ=<dir> actually sets the path
relative to which file I/O is performed (the original poster's apparent
question) as well as the location where .Data directory is looked for (and
also the .Prefs location). These are independent settings in
S-PLUS. These settings can also be controlled independently via the
command line variables S_CWD, S_DATA, and S_PREFS. See the "Programmer's
Guide" for details on all the command line switches: "Chapter 18: The
S-PLUS Command Line and the System Interface".
Note however that these are completely independent settings -- changing the
database attached in position 1 has absolutely no effect on the location
where file(), read.table(), etc. look for files.
-- Tony Plate
At Thursday 09:25 PM 9/23/2004, Richard M. Heiberger wrote:
There are two distinct interpretations of your question.
Let me try both.
1. Change the .Data that is first on your search() list.
The .Data directory must already exist and you must have write permission.
attach("c:/HOME/tmp/.Data", pos=1)
Now all S-Plus objects that you create by assignment
a <- 2:5
will be written in c:/HOME/tmp/.Data
2. Change the location where files other than S-Plus objects are
read and written. In my usual setup, I start S-Plus from
the c:/HOME/rmh directory and c:/HOME/rmh/.Data is in the first
position of my search() list. A statement of the form
myData <- read.table("myData.csv")
will find the file c:/HOME/rmh/myData.csv
I wish to read some data from another location, say from c:/datasets/
Define a function
datasets <- function(filename) paste("c:/datasets", filename, sep="/")
Then access the file with
myData <- read.table(datasets("myData.csv"))
This will read the file c:/datasets/myData.csv
The advantage of a function is that it can be changed external to the
read.table statement. Indeed, it can define a different directory on
every computer you use and still work without changing any code.
My impression of your original question is that you were trying to
solve the second interpretation by a method appropriate to the first
interpretation.
Hui-May_Chu@vrtx.com gave a method similar to the second interpretation.
Tony Plate <tplate@blackmesacapital.com> was suggesting a startup
method equivalent to the first interpretation.
Rich
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|