From @okol @ending from in@@-toulou@e@fr  Mon May 14 16:00:14 2018
From: @okol @ending from in@@-toulou@e@fr (Serguei Sokol)
Date: Mon, 14 May 2018 16:00:14 +0200
Subject: [Rd] access an element with empty name
In-Reply-To: <23289.38243.173216.323929@hornik.net>
References: <0477dba5-4e80-84ab-7ea5-51b670de88fc@insa-toulouse.fr>
 <23289.38243.173216.323929@hornik.net>
Message-ID: <d8918e0b-a932-9d76-c925-21c6e1cb9b6d@insa-toulouse.fr>

Le 14/05/2018 ? 15:55, Kurt Hornik a ?crit?:
>>>>>> Serguei Sokol writes:
>> Hi,
>> I came across a case where I cannot access a list element by its empty name.
>> Minimal example can be constructed as
>>   ??? x=list("A", 1)
>>   ??? names(x)=c("a", "")
>>   ??? x[["a"]]
>>   ??? #[1]? "A"
>>   ??? x[[""]]
>>   ??? #NULL
>>   ??? x$`a`
>>   ??? #[1]? "A"
>>   ??? x$``
>>   ??? # Error: attempt to use zero-length variable name
>>   ??? # but we can still access the second element by its index
>>   ??? x[[2]]
>>   ??? #[1] 1
>> To my mind, it should be perfectly legal to access an element by an
>> empty name as we can have for example
>>   ??? match("", names(x))
>>   ??? #[1] 2
>> Hence a traditional question: is it a bug or feature?
> A feature according to the docs: ? Extract says
>
>      Neither empty (?""?) nor ?NA? indices match any names, not even
>      empty nor missing names.
>

Thanks Kurt, I missed that one.



[Rd] access an element with empty name
Serguei Sokol