r-lib / vctrs

Generic programming with typed R vectors

Home Page:https://vctrs.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vctrs objects loose names when apply is used on them

thomasp85 opened this issue · comments

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

I think this is actually a duplicate of #1416