[Rd] Scoping bug in ftable() (PR#6541)
Kurt Hornik
Kurt.Hornik at wu-wien.ac.at
Thu Feb 5 09:05:24 MET 2004
>>>>> Duncan Murdoch writes:
> 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.
Of course I longer recall the details but I think what I tried was
essentially to do table(..., exclude = exclude) in a way that would use
the table() heuristics for getting dimnames as if table() had been
called directly (rather than via ftable()).
Now the problem in what we currently have is that in the above:
R> x <- 1:2
R> y <- 3:4
R> ftable(z = x+1, y)
y 3 4
x + 1
2 1 0
3 0 1
and the first one should definitely be 'z' ... at least, according to my
original intentions :-)
And of course, pls note that we have
R> table(z=x+1, y+1)
z 4 5
2 1 0
3 0 1
in both r-release and r-devel so perhaps this is the problem we need to
fix first ...
Best
-k
More information about the R-devel
mailing list