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.
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.One way to avoid this is to use
y = c(b = unname(x[1]*2))
, but this is clunky.