r-hyperspec / hyperSpec

hyperSpec: Tools for Spectroscopy (R package)
https://r-hyperspec.github.io/hyperSpec/
GNU General Public License v3.0
12 stars 3 forks source link

Improve code in `wl_convert_units.hyperSpec()` #70

Open GegznaV opened 2 years ago

GegznaV commented 2 years ago
Basing on the lines from `R/wl_convert_units.R` (see [this comment](https://github.com/r-hyperspec/hyperSpec/pull/30/files?file-filters%5B%5D=.R#r687606832) ), this `switch` sentence: ```r x@label$.wavelength <- switch(.wl_fix_unit_name(to), nm = expression("Wavelength, nm"), invcm = expression(tilde(nu) / cm^-1), ev = expression("Energy / eV"), freq = expression(nu / THz), raman = expression(Raman ~ shift / cm^-1), to ) ``` Could be replaced with: ```r x@label$.wavelength <- wl_create_label_from_units(to, on_failure = "pass as-is") ```

The issue is that the default labels would change too.

Related: #69

bryanhanson commented 2 years ago

Spam