From dmurdoch at pair.com  Thu Feb  5 07:09:58 2004
From: dmurdoch at pair.com (Duncan Murdoch)
Date: Thu Feb  5 07:10:05 2004
Subject: [Rd] Scoping bug in ftable() (PR#6541)
In-Reply-To: <Pine.LNX.4.44.0402042108070.17491-100000@itasca2.stat.uiowa.edu>
References: <20040204183230.F3CFCEDDF@slim.kubism.ku.dk>
	<Pine.LNX.4.44.0402042108070.17491-100000@itasca2.stat.uiowa.edu>
Message-ID: <e0n320tq4rov962q1gu4qjkik0hvd9lc1k@4ax.com>

On Wed, 4 Feb 2004 21:21:35 -0600 (CST), Luke Tierney wrote:

>On Wed, 4 Feb 2004 dmurdoch@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


[Rd] Scoping bug in ftable() (PR#6541)
Duncan Murdoch