[Rd] rm() deletes 'c' if c('a','b') is the argument (PR#9399)

bill at insightful.com bill at insightful.com
Wed Nov 29 23:04:17 CET 2006


On Wed, 29 Nov 2006 p.dalgaard at biostat.ku.dk wrote:

> > A character vector c('a','b') is supplied to rm().
> > As a result, 'c' is deleted unintentionally.
> > ...
> >> a <- 1:5
> >> b <- 'abc'
> >> c <- letters
> >> ls()
> > [1] "a" "b" "c"
> >> rm(c('a','b'))
> >> ls()
> > character(0)
> ...
> I don't know if it really qualifies as a bug, but it's not documented
> that as.character() is used and I suppose we could be more careful with
> the argument checking.

I suggest that if any changes are made, then
rm(c('a','b')) should throw an error.

Functions which try to be "user-friendly" by
letting you omit quotes are generally a bad
idea, IMO.  They all need patching up in various
ways to work in all situation (e.g., library's
character.only=TRUE argument and the complicated
code in help to see what the topic really is).

Perhaps rm() should be deprecated in favor of
remove(), which uses standard S syntax rules.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."



More information about the R-devel mailing list