RE: Organizing data

Gebhart, Kristi (
Fri, 30 Jan 1998 09:03:28 -0700

I keep my projects in subdirectories below e:\splus\projects. In the
S-PLUS default directory I keep functions common to several projects
such as unit conversions, etc. Below is a little function that I use to
move between project directories. I didn't write it, but lifted it from
some S-PLUS book or manual which I failed to document. Perhaps someone
on the list is the author?? It used to work better in S-PLUS 3.3
because it would actually create the directory if it didn't exist but I
couldn't get that to work in ver 4 so took it out. I would be nice to
add the functionality that it would also open or create the object
browser for the specified project, but I haven't had a chance to play
with that.

Kristi A. Gebhart
Research Physical Scientist
National Park Service, Air Resources Division
CIRA, Colorado State University
Fort Collins, CO 80523
(970) 491-3684 (voice)
(970) 491-8598 (fax)

# function project(dir)
# Attaches the specified project directory first in search list
# Prompt is changed to the project name
# If called with no arguements it returns to _data
active <- exists("cur.collection") && length(cur.collection) > 0
result <- if(active) cur.collection else character(0)
if(missing(dir)) {
if(active) {
options(prompt = "> ") # restore prompt
assign("cur.collection", character(0), frame =
else {
realdir <- paste("e:\\splus\\projects\\", dir,
"\\_Data", sep = "")
if(!is.dir(realdir)) {
print(paste(realdir, "does not exist."))
stop(message = "Create this directory and try
attach(realdir, pos = 1)
assign("cur.collection", dir, frame = 0)
options(prompt = paste(dir, "> "))