Closed Schuch666 closed 1 year ago
Are you on Windows, right? This is an upstream bug for that platform. On Unix, your example works just fine. See #301.
A better workaround would be to handle moles properly. I.e., a mole is not a gram; instead, a mole of something could be a gram of that something. Thus, a better approach would be to define the conversion from a new unit g_something
to the existing mole.
Quick example:
library(units)
#> udunits database from /usr/share/udunits/udunits2.xml
install_unit("g_oxigen", "1/16 mol")
install_unit("g_carbon", "1/12 mol")
(x <- set_units(1, mol))
#> 1 [mol]
(y <- set_units(x, g_oxigen))
#> 16 [g_oxigen]
set_units(y, g_carbon)
#> 12 [g_carbon]
Hi @Enchufa2
Thanks for the reply.
I will check the possibility to implement this in the future, currently this is part of a function inside a package that need to runs on all platforms and this part handle the conversion of emissions of aerosol and gases to the units needed to air quality models (ug m-2 s-1 and MOL km-1 h-1), this is a simple part but should work for any arbitrary value of mm (the user has the option to use 1 for special cases, for example if the input data is in a different unit or is already in MOL or is a mix of many species).
Currently this is a flexible function for any species and is the user that has to put the wanted mm value, more responsibility but more power
Hi @Enchufa2 A quick update, this error also happen in Debian check https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-clang/EmissV-00check.html
This is quite strange. I am unable to reproduce this. Do we know by any chance what version of udunits2 is in there? Is there anything in common with the Windows machine?
This probably had something to do with the toolchain... I didn't manage to reproduce this, sorry. Please feel free to reopen if you find this issue again.
I got this 'error' related to install a unit MOL for the case of '1 MOL = 1 g', this is the error:
Error in ud_map_symbols(symbol, ut_unit) : Unit already maps to "g"
This happen in the new version (used to work in previous version), why there is this new limitation?
This reproduces the expected results
Changing to mm = 1 make the error in install_unit.
This is the workaround:
I got this solution but there is a better way to do that?
Thanks