From Kurt.Hornik at wu-wien.ac.at  Fri Oct 17 09:04:40 2003
From: Kurt.Hornik at wu-wien.ac.at (Kurt Hornik)
Date: Fri Oct 17 09:05:51 2003
Subject: [Rd] data() misbehaving inside a function
In-Reply-To: <x2u169ngpg.fsf@biostat.ku.dk>
References: <20031016141029.A22651@jessie.research.bell-labs.com>
	<x2u169ngpg.fsf@biostat.ku.dk>
Message-ID: <16271.38024.30026.993340@mithrandir.hornik.net>

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

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

-k


[Rd] data() misbehaving inside a function
Kurt Hornik