From murdoch.duncan at gmail.com  Thu Aug 21 15:47:52 2014
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Thu, 21 Aug 2014 09:47:52 -0400
Subject: [Rd] The behaviour of setting names differs between lists and
 atomic vectors
In-Reply-To: <CAPp_+=fwKAD19GAce7veeZMndmZ9W7aKm+MN393ZCz-jD=80fQ@mail.gmail.com>
References: <CAPp_+=fwKAD19GAce7veeZMndmZ9W7aKm+MN393ZCz-jD=80fQ@mail.gmail.com>
Message-ID: <53F5F888.4020602@gmail.com>

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")).

Duncan Murdoch



[Rd] The behaviour of setting names differs between lists and atomic vectors
Duncan Murdoch