r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
290 stars 66 forks source link

vctrs objects loose names when apply is used on them #1914

Closed thomasp85 closed 9 months ago

thomasp85 commented 9 months ago

It appears vctrs objects will throw away their names when mapped over, in contrast to how names generally behaves with mapping (the names is transferred to the result)

names(lapply(vctrs::new_vctr(list(a = 1, b = 2)), identity))
#> NULL
names(lapply(list(a = 1, b = 2), identity))
#> [1] "a" "b"

This is due to as.list() throwing away the names

DavisVaughan commented 9 months ago

I think this is actually a duplicate of https://github.com/r-lib/vctrs/issues/1416