[Rd] Scoping bug in ftable() (PR#6541)
Duncan Murdoch
dmurdoch at pair.com
Thu Feb 5 07:09:58 MET 2004
On Wed, 4 Feb 2004 21:21:35 -0600 (CST), Luke Tierney wrote:
>On Wed, 4 Feb 2004 dmurdoch at pair.com wrote:
>> I think the
>> problem is in this line:
>>
>> x <- do.call("table", c(as.list(substitute(list(...)))[-1],
>> list(exclude = exclude)))
...
>> I think this works:
>>
>> args <- list(...)
>> names(args) <-
>> as.character(unlist(as.list(substitute(list(...)))))[-1]
x <- do.call("table", c(args,list(exclude=exclude))
(which is what I committed, not what I wrote in the original message)
>>
>> but isn't there an easier way?
A much simpler way that probably does what was originally intended is
this:
x <- table(..., exclude=exclude)
This works fine on the example I posted. Where it differs from my
solution is when expressions are passed:
It gives
> x <- 1:2
> y <- 3:4
> ftable(x+1, y+1)
4 5
2 1 0
3 0 1
whereas the current r-devel code gives
> ftable(x+1, y+1)
y + 1 4 5
x + 1
2 1 0
3 0 1
I like the new behaviour better, so I'll leave the complicated version
in place.
Duncan Murdoch
More information about the R-devel
mailing list