This is the most general way of specifying conversion between
user-defined units. The function installes a one-way conversion from one
unit to another through a general function, f
, that must take one
numeric argument and return one numeric argument. When the units
package tries to convert between units, it will look up from
and
to
to see if it can find a conversion function. If it can, it will
call f
and consider the value converted from unit from
to
unit to
.
It is the user's responsibility to install a conversion from to
back
to from
as well. One-way conversion does not work well with the
units
package, since conversion is done in several places for unit
expression simplification and if a unit can only be converted in one
direction, this simplification will not work correctly.
For conversion that can be done as a linear function, \(y = \alpha x +
\beta\), you should instead use the
install_conversion_constant
function. This function will
automatically install conversion functions for both directions of unit
conversion.