From maechler at stat.math.ethz.ch  Fri Oct 17 09:28:59 2003
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri Oct 17 09:28:05 2003
Subject: [Rd] data() misbehaving inside a function
In-Reply-To: <16271.38024.30026.993340@mithrandir.hornik.net>
References: <20031016141029.A22651@jessie.research.bell-labs.com>
	<x2u169ngpg.fsf@biostat.ku.dk>
	<16271.38024.30026.993340@mithrandir.hornik.net>
Message-ID: <16271.39483.58310.535259@gargle.gargle.HOWL>

>>>>> "KH" == Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
>>>>>     on Fri, 17 Oct 2003 09:04:40 +0200 writes:

>>>>> Peter Dalgaard writes:
    >> David James <dj@research.bell-labs.com> writes:
    >>> Calls of the form data(package = pkg) inside a function 
    >>> incorrectly fail ("pkg" is a local variable).  For instance,
    >>> 
    >>> foo <- function(pkg) data(package = pkg)
    >>> foo("base")
    >>> Error in .find.package(package, lib.loc, verbose = verbose) :
    >>> none of the packages were found

    >> This is pretty much unavoidable if you want a function to accept
    >> unquoted names. It's not in principle different from

    >> women <- "airquality"
    >> data(women)

    >> not being equivalent to data("airquality"). Some functions (library(),
    >> require(), demo()) have a character.only argument to prevent it, and I
    >> suppose we should consider putting it on help() and data() as well.

    KH> Or get rid of non-standard evaluation and educate users to use quoted
    KH> strings where strings should be used.

and infuriate those who know and used the S language for more
than 15 years, where  help(help)  has always worked? 

Definitely not worth the pain (I *know* I'd hear ... comments from them!)!
I'd go for adding `character.only'.

Martin


[Rd] data() misbehaving inside a function
Martin Maechler