There was a pre-existing bug.  ?source in 2.0.1 says

    file: a connection or a character string giving the name of the
          file or URL to read from.

yet it contained

    if (chdir && (path <- dirname(file)) != ".") {

You cannot reasonably run dirname() on a connection or a URL, and it throws an error in those cases.

We need a more elaborate detection mechanism, and some re-ordering of the code.


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?

Luca

+-----------------------------------------------------------------------+
| Dr. Luca Scrucca                                                      |
| Dipartimento di Economia, Finanza e Statistica                        |
| Sezione di Statistica                          tel. +39-075-5855226   |
| Università degli Studi di Perugia              fax. +39-075-5855950   |
| Via Pascoli - C.P. 1315 Succ. 1                                       |
| 06100 PERUGIA  (ITALY)                                                |
|                                                  (o_   (o_   (o_      |
| E-mail:   [EMAIL PROTECTED]                    //\   //\   //\       |
| Web page: http://www.stat.unipg.it/luca         V_/_  V_/_  V_/_      |
+-----------------------------------------------------------------------+

______________________________________________
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


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

Reply via email to