r-lib / rray

Simple Arrays
https://rray.r-lib.org
GNU General Public License v3.0
130 stars 12 forks source link

`vec_cast()` should preserve dim names #249

Open DavisVaughan opened 4 years ago

DavisVaughan commented 4 years ago

Follow whatever strategy we end up with here

https://github.com/r-lib/vctrs/issues/623

DavisVaughan commented 4 years ago

If we end up recycling names when doing a cast that requires broadcasting, it might make sense to make rray_broadcast() also recycle names. Meaning these should be aligned.


vctrs::vec_cast(
  matrix(1, dimnames = list("r1", "c1")),
  matrix(1, ncol = 2)
)
#>    c1 c1
#> r1  1  1

rray::rray_broadcast(
  matrix(1, dimnames = list("r1", "c1")), 
  c(1, 2)
)
#>    [,1] [,2]
#> r1    1    1

Created on 2019-10-17 by the reprex package (v0.2.1)