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

2023-09-11 Thread Trevor Davis
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]]

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


Re: [Rd] List's `[[` method with "" tag

2023-09-11 Thread Sergueï Sokol via R-devel
It's per design: 

?names
...
The name '""' is special: it is used to
indicate that there is no
name associated with an element of a (atomic
or generic) vector.
Subscripting by '""' will match nothing (not even
elements which
have no name).
... 

Best,
Serguei. 

Le 2023-09-11
18:29, Trevor Davis a écrit :

> 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]]
> 
> __
>
R-devel@r-project.org mailing list
>
https://stat.ethz.ch/mailman/listinfo/r-devel
 
[[alternative HTML version deleted]]

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


Re: [Rd] FYI: daily R source tarballs from ETH: *.xz instead of *.bz2)

2023-09-11 Thread Prof Brian Ripley

On 09/09/2023 01:56, Hervé Pagès wrote:

Hi Martin,

Sounds good. Are there any plans to support the xz compression for
package source tarballs?


What makes you think it is not supported?

R CMD INSTALL happily installs .tar.xz files, and the name is not used 
to detect compression so .tar.gz files could be bzip2- or xz-compressed.


Note that tarball compression is pretty much irrelevant where the 
tarball contains large compressed files, for example .rda files or 
vendor.tar.xz files of Rust sources.  You have to arrange that the first 
compression is the bast possible.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

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