[Rd] 'identical' and the warning "ignoring non-pairlist attributes"

Niels Richard Hansen Niels.R.Hansen+lists at math.ku.dk
Sun Dec 12 07:49:16 CET 2010



On 11/12/10 12.47, peter dalgaard wrote:
>
> On Dec 11, 2010, at 11:23 , peter dalgaard wrote:
>
>>
>> On Dec 11, 2010, at 08:23 , Niels Richard Hansen wrote:
>>
>>> Dear R developers
>>>
>>> Using the 'foreach' package I encounter warnings like
>>>
>>> Warning message: In identical(.combine, cbind) : ignoring non-pairlist
>>> attributes
>>>
>>> Warnings appear once in a new R-session when I run a particular piece of
>>> code - and not again. I understand from the source code of 'identical'
>>> that the function checks and believes that .combine and cbind have
>>> non-pairlist attributes, but I don't understand how this can be the case
>>>
>>> I have produced the following minimal example
>>>
>>> data.frame()[rep(1,1e6), ] library(foreach)
>>> identical(foreach:::defcombine, cbind)
>>>
>>> resulting in
>>>
>>> [1] FALSE Warning message: In identical(foreach:::defcombine, cbind) :
>>> ignoring non-pairlist attributes
>>>
>>> The warning is not related to the foreach package it seems. I get the
>>> same kind of warning with e.g.
>>>
>>> identical(spatial:::trmat, cbind)
>>>
>>> in a new R-session. Many other functions I have tried do, however, not
>>> result in the warning. The warning depends on the supposedly completely
>>> unrelated data frame operation. It seems also to be related to the fact
>>> that the data frame is empty and I extract a large number of columns out
>>> of this empty data frame. I would highly appreciate help on this to get
>>> rid of the warning in my own package.
>>
>> Hm, I think you might have tickled a buglet here. I can debug it down to a
>> comparison of two CHARSXPs, both having CHARSXP attributes. I'm a getting a
>> little rusty on debugging at that level, but I don't think CHARSXPs are
>> supposed to _have_ attributes in any meaningful context, so perhaps
>> identical() just shouldn't check. On the other hand, it could also be the
>> sign of a memory overrun in the preceding memory-intensive operation.
>>
>
> Robert Gentleman pointed out offlist that attributes of CHARSXP are being
> used for cacheing and hashing, so skipping the comparison is what makes
> sense. I have fixed this for R-devel now (tampering with 2.12.1 RC for this
> sort of reason is probably best avoided).
>
>

Peter, thanks for looking into this. I know very little about the R
implementation at the level you are talking about. For the record
it is pretty easy to avoid the warning by checking and _not_
doing the inefficient subsetting of an empty data frame ...

- Niels

-- 
Niels Richard Hansen                     Web:   www.math.ku.dk/~richard	
Associate Professor                      Email: Niels.R.Hansen at math.ku.dk
Department of Mathematical Sciences             nielsrichardhansen at gmail.com
University of Copenhagen                 Skype: nielsrichardhansen.dk	
Universitetsparken 5                     Phone: +1 510 502 8161	
2100 Copenhagen Ø
Denmark



More information about the R-devel mailing list