r-quantities / units

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

symbolic_unit is deprecated. #279

Closed ibarraespinosa closed 3 years ago

ibarraespinosa commented 3 years ago

Hello, I`m getting the warning

Warning messages:
1: 'units::install_symbolic_unit' is deprecated.
Use 'install_unit' instead.
See help("Deprecated")

I use units::install_symbolic_unit("veh", warn = F) to define a new symbolic unit named "veh" for vehicles.

https://github.com/atmoschem/vein/blob/94ce7e960c1a48bbfcff35c7002530fc71740fdc/R/Vehicles.R#L31

I have tried using install_unit but the program gives error because "veh" is already defined. Is it possible to add a warn logical argument similar to install_symbolic_unit?

Also, I have a function named remove_units, simialr to drop_units where I remove units converting as.numeric https://github.com/atmoschem/vein/blob/94ce7e960c1a48bbfcff35c7002530fc71740fdc/R/remove_units.R#L21

Is it wrong remove units using as.numeric?

Enchufa2 commented 3 years ago

Hello, I`m getting the warning

Warning messages:
1: 'units::install_symbolic_unit' is deprecated.
Use 'install_unit' instead.
See help("Deprecated")

I use units::install_symbolic_unit("veh", warn = F) to define a new symbolic unit named "veh" for vehicles.

https://github.com/atmoschem/vein/blob/94ce7e960c1a48bbfcff35c7002530fc71740fdc/R/Vehicles.R#L31

I have tried using install_unit but the program gives error because "veh" is already defined. Is it possible to add a warn logical argument similar to install_symbolic_unit?

Sorry, but this was a bad pattern that we do not want to revisit with the new interface. You shouldn't add a unit each time you call a function. Instead, add all units you need at startup, using the .onLoad function (and it would be nice to remove them .onUnload too).

Also, I have a function named remove_units, simialr to drop_units where I remove units converting as.numeric https://github.com/atmoschem/vein/blob/94ce7e960c1a48bbfcff35c7002530fc71740fdc/R/remove_units.R#L21

Is it wrong remove units using as.numeric?

It is fine to use as.numeric as long as you always want to succeed in that call, because drop_units fails if the object has no units.

ibarraespinosa commented 3 years ago

Alright! Many thanks!