From trevor@|@d@v|@ @end|ng |rom gm@||@com  Mon Sep 11 18:29:26 2023
From: trevor@|@d@v|@ @end|ng |rom gm@||@com (Trevor Davis)
Date: Mon, 11 Sep 2023 09:29:26 -0700
Subject: [Rd] List's `[[` method with "" tag
Message-ID: <CAMigB8FTRq5BeY8nHfukwyk=kBNQ1k6EHfsKRv6EEZytLC9=og@mail.gmail.com>

Hi,

I notice that one can assign a variable to an R list by using an empty
string key but one cannot get that variable back from the list by using the
empty string key:

```r
l <- list()
l[[""]] <- "An empty string as list key"
names(l)
l[[""]] # Returns a `NULL`
l[[names(l) == ""]] # Returns first value with `""` tag
```

Instead of `l[[""]]` returning a `NULL` I'd "expect" it to instead return
the first variable named `""`  i.e. in this case "An empty string as list
key".  It would be nice if the `[[` method of a list was updated to "fix"
this.

Additionally, I observe that if a list is named but has certain elements
without names then those are currently "named" `""`:

```r
names(list(a = 1, 2, c = 3, 4))
```

This latter change may be a breaking change but I speculate that perhaps it
may be more intuitive if missing names were indicated with `NA_character_`
instead of `""`.

Thanks,

Trevor

	[[alternative HTML version deleted]]



[Rd] List's `[[` method with "" tag
Trevor Davis