Skip to content
Prev 176888 / 398503 Next

Physical Units in Calculations

On Sun, Apr 12, 2009 at 11:01 PM, <Bill.Venables at csiro.au> wrote:
I'd think it would be far simpler and cleaner to have a single
dimensioned-units class with a slot for magnitude and one for the
power of each dimension -- M, L, T are uncontroversial, pick your
system for electromagnetism and thermodynamics....  Once you have
that, you have not just mass, length, and time, but also area, volume,
density, acceleration, viscosity, etc. etc.

It would of course be nice if the existing difftime class could be fit
into this, as it is currently pretty much a second-class citizen.  For
example, c of two time differences is currently a numeric vector,
losing its units (hours, days, etc.) completely.

One of the difficulties of adding units would be, I suspect, making
them work nicely with the rest of the system.  For example, although
sum is defined abstractly in terms of '+', as far as I can tell
sum.units would have to be overloaded explicitly. Similarly for mean,
cumsum, rle, var, %*%, etc. etc.

              -s