r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
172 stars 27 forks source link

Cannot convert mass-to-charge ratio to Thomson #319

Closed wiedenhoeft closed 2 years ago

wiedenhoeft commented 2 years ago

The thomson (Th), a mass-to-charge ratio defined as a constant times kg/C, is apparently supported by the package:

set_units(1:4, Th) Units: [Th] [1] 1 2 3 4

Yet, the following conversion fails under R-4.2 x86_64-pc-linux-gnu, package version 0.8-0:

set_units(set_units(1:4, kg/C), Th) Error: cannot convert kg/C into Th

Enchufa2 commented 2 years ago

The Thomson is not present in the udunits2 database. That is recognised as "hours" with prefix "tera", so tera-hours:

set_units(set_units(1:4, Th), "min")
#> Units: [min]
#> [1] 6.0e+13 1.2e+14 1.8e+14 2.4e+14

You could ask upstream to add it, but I don't think they will be willing so, because this unit was deprecated by IUPAC. You can also define it yourself:

install_unit("Th", "1.036426e-8 kg/C")
set_units(set_units(1:4, Th), "kg/C")
#> Units: [kg/C]
#> [1] 1.036426e-08 2.072852e-08 3.109278e-08 4.145704e-08