a problem sourcing a file using chdir=TRUE
This and some related problems should be fixed in tomorrow's R-patched snapshot.
On Mon, 16 May 2005, Luca Scrucca wrote:
Dear R-users, I used to give commands such as:
source(file="~/path/to/file.R", chdir=TRUE)
but with the latest v. 2.1.0 it does not seem to work anymore. I tried to figure out what it was going on and it seems that the string for which
class(file)
[1] "character" is changed to
class(file)
[1] "file" "connection"
when the connection is open by
file <- file(file, "r", encoding = encoding)
But this force the following if statement
if (chdir && is.character(file) && (path <- dirname(file)) != ".")
{ owd <- getwd()
on.exit(setwd(owd))
setwd(path)
}
to be FALSE and then non changing of current directory is done.
Is this the desired behavior or some bug fix is required?
Brian D. Ripley, ripley at stats.ox.ac.uk 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