On 21 Aug 2014, at 15:47 , Duncan Murdoch <murdoch.dun...@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


> Duncan Murdoch
> 
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to