From simon.urbanek at r-project.org  Tue Oct  2 19:55:00 2007
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 2 Oct 2007 13:55:00 -0400
Subject: [Rd] pairlist objects
In-Reply-To: <1191292109.4701accd24217@webmail.fhcrc.org>
References: <1191292109.4701accd24217@webmail.fhcrc.org>
Message-ID: <AAFE4514-2403-4B51-8E49-782DCA6FF77B@r-project.org>


On Oct 1, 2007, at 10:28 PM, hpages at fhcrc.org wrote:

> ?pairlist gives no explanation about what exactly is the difference  
> between a pairlist and a list (except that a pairlist of length 0  
> is 'NULL'). So, what's a pairlist?
>

I read "traditional _dotted pair_ lists (as in LISP)" there - c.f. also
http://cran.r-project.org/doc/manuals/R-lang.html#Pairlist-objects



> class(.Options)
> [1] "pairlist"
>
> Some strange things about the "pairlist" type:
>
>> showClass("pairlist")
>   Error in getClass(Class) : "pairlist" is not a defined class
>
> Why the above doesn't work?

Because "pairlist" is not a formal class. Why should it?


> It works for "list":
>
>> showClass("list")
>
>   No Slots, prototype of class "list"
>
>   Extends: "vector"
>
>> is.list(.Options)
>   [1] TRUE
>
>> is.vector(.Options)
>   [1] FALSE
>
> This doesn't make sense! If 'x' is a list, then it should be  
> considered a vector too.
>

Why? They are completely different objects. lists are generic  
vectors, pairlists are not vectors (c.f. the docs above).


> Subsetting a pairlist with [] doesn't produce a pairlist:
>
>> class(.Options[1:3])
>   [1] "list"
>
> Yes, this one is documented, but still...
>

As the docs say, on R level pairlists are usually converted to  
vectors as the use of pairlists is deprecated.

Cheers,
Simon



[Rd] pairlist objects
Simon Urbanek