Last weekend I submitted an update of my R package
datamart to CRAN. It has been more than a half year since the last update, however there are only minor advances. The package is still in its early stages, and very experimental.
One new feature is the function
iconv, but instead of converting character vectors between different encodings, this function converts numerical vectors between different units of measurements. Now if you want to know how many centimeters one horse length is, you can write in R:
> #install.packages("datamart") > library(datamart) > uconv(1, "horse length", "cm")
and you will get the answer 240. I had the idea for this function when I had to convert between various energy units, including natural units of energy fuels like cubic metres of natural gas. The
uconv function supports this, using common constants for the conversion.
> uconv(1, "Mtoe", "PJ")  41.88 > uconv(1, "m³ NG", "kWh")  10.55556
These conversions may be ambigious. For instance, the last one combines a volume and an energy dimension. An optional parameter allows the specification of the context, or
> uconv(1, "Mtoe", "PJ", uset="Energy")
The currently available unit sets and units therein can be inspected with
The first argument can be a numerical vector:
> set.seed(13) > uconv(37+2*rnorm(5), "°C", "°F", uset="Temperature")  100.59558 97.59102 104.99059 99.27435 102.71309