From maechler at stat.math.ethz.ch  Mon Aug 25 17:53:58 2014
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 25 Aug 2014 17:53:58 +0200
Subject: [Rd] The behaviour of setting names differs between lists
	and	atomic vectors
In-Reply-To: <43333C94-B4C2-43FB-ADC8-582FD089F776@gmail.com>
References: <CAPp_+=fwKAD19GAce7veeZMndmZ9W7aKm+MN393ZCz-jD=80fQ@mail.gmail.com>
	<53F5F888.4020602@gmail.com>
	<43333C94-B4C2-43FB-ADC8-582FD089F776@gmail.com>
Message-ID: <21499.23574.26909.459333@stat.math.ethz.ch>

>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>>     on Thu, 21 Aug 2014 16:11:38 +0200 writes:

    > On 21 Aug 2014, at 15:47 , Duncan Murdoch
    > <murdoch.duncan at gmail.com> wrote:

    >> On 21/08/2014 9:26 AM, Richard Cotton wrote:
    >>> If you set the names in a list, some cat-style
    >>> processing seems to happen.  For example, backslashes
    >>> are modified.  This behaviour doesn't happen with atomic
    >>> vectors.  Compare, for example:
    >>> 
    >>> setNames(1, "a\\b") ## a\\b ## 1 setNames(list(1),
    >>> "a\\b") ## $`a\b` ## [1] 1
    >>> 
    >>> Notice that the name of the element in the list has been
    >>> changed to 'a', 'backspace'.
    >>> 
    >>> Is this behaviour intended, or a bug?
    >>> 
    >> I think there's a bug, but not in names<- (or setNames,
    >> which calls it).  The bug is in the printing, as you'll
    >> see if you look at names(setNames(list(1), "a\\b")).
    >> 

    > Yep, slight variant:

    >> l <- list(`a\\b`=1) l
    > $`a\b` [1] 1

    >> l$`a\b`
    > NULL
    >> l$`a\\b`
    > [1] 1

With thanks to the OP, Richie,
this is now  fixed in  R-devel and R-patched, i.e., in any next
version of R.

Martin Maechler,
ETH Zurich



[Rd] The behaviour of setting names differs between lists and atomic vectors
Martin Maechler