Re: [R] a problem sourcing a file using chdir=TRUE

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 17 May 2005 - 20:26:39 EST

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@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

______________________________________________
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
Received on Tue May 17 20:32:21 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:47 EST