hadley / strict

Make R a little bit stricter
235 stars 10 forks source link

Stricter naming rules for named vectors #26

Open noamross opened 7 years ago

noamross commented 7 years ago

I'm not sure the best way to address this, but I would love to have a stricter way of assigning names to vectors whose components may have names. When you create a named vector with c(), the names of underlying arguments can modify the names of the output.

x = c(a = 1)
y = c(b = x[1]*2)
y
#> b.a 
#>   2
x = c(1)
z = c(b = x[1]*2)
z
#> b 
#> 2

One way to avoid this is to use y = c(b = unname(x[1]*2)), but this is clunky.

hadley commented 7 years ago

I think probably the best we can do is provide a better concatenation function in vctrs