Skip to content

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

2 messages · Peter Dalgaard, Duncan Murdoch

#
Steven McKinney wrote:
The reason is that
 > x <- function(...) sapply(match.call(expand.dots = FALSE)$..., 
as.character)
 > x(c(a,b))
     [,1]
[1,] "c"
[2,] "a"
[3,] "b"

Which in turn happens because
 > as.character(quote(c(a,b)))
[1] "c" "a" "b"

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.
#
On 11/29/2006 3:31 PM, p.dalgaard at biostat.ku.dk wrote:
I'd say it qualifies as a bug if we remove something that the user 
didn't ask to have removed.   A user would have a right to be annoyed if

rm( NotNeeded("a", "b") )

(where NotNeeded was a function to give the subset of variables which 
are not needed) went ahead and removed all the variables, *plus* the 
NotNeeded function!

Duncan Murdoch