This function generalizes the additive and multiplicative decompositions
for arithmetic and geometric indexes by Balk (2008, Chapter 4). It returns
a value such that
gmean(x, w, r) == gmean(x, transmute_weights(x, w, r, s), s)
Transmuting weights returns a value that is the same length as x,
so any missing values in x or weights will return NA.
Unless all values are NA, however, the result will still satisfy
the above identity when na.rm = TRUE.