Merge two spectra into a single spectrum of the same class interspersing rows to sort wavelength values.
Usage
rmerge_spct(x, y, ids = c(x = "x", y = "y"), strict.wls = FALSE, fill = TRUE)Arguments
- x, y
generic_spct or of the same derived class, containing each data for a single spectrum.
- ids
character Named vector with the names to use to identify the origin of the rows.
- strict.wls
logical If
TRUEthe presence of the same wavelengths inxandytriggers an error. IFALSEa message is issued and when a wavelength is bothxand iny, the row fromyprevails.- fill
logical If
TRUEfills missing columns with NAs. By defaultTRUE. WhenTRUE,use.nameshas also to beTRUE, and all items of the input list have to have non-null column names.
Value
An object of the same class as x and y with data for
columns shared by x and y based on names.
Details
Two objects belonging to the same class, and containing each data
for a single spectrum are row bound keeping wavelengths sorted. Only
columns present in both x and y are preserved if fill =
FALSE and otherwise missing values are filled with NA.
See also
Other Methods for row-binding spectra:
rbind_spct()
Examples
rmerge_spct(sun.spct[-(1:3), ], sun.spct[1:3, ])
#> Object: source_spct [522 x 4]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm
#> Label: sunlight, simulated
#> Measured on 2010-06-22 09:51:00 UTC
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1]
#> --
#> # A tibble: 522 × 4
#> w.length s.e.irrad s.q.irrad id
#> <dbl> <dbl> <dbl> <chr>
#> 1 280 0 0 y
#> 2 281. 0 0 y
#> 3 282. 0 0 y
#> 4 283. 0 0 x
#> 5 284. 0 0 x
#> 6 285. 0 0 x
#> 7 286. 0 0 x
#> 8 286. 0 0 x
#> 9 287. 0 0 x
#> 10 288. 0 0 x
#> # ℹ 512 more rows
rmerge_spct(peaks(white_led.source_spct, span = NULL),
wls_at_target(white_led.source_spct),
ids = c(x = "peak", y = "fwhm"))
#> Object: source_spct [3 x 3]
#> Wavelength range 540.94-660.78 nm, step 57.17-62.67 nm
#> Label: led_desk201
#> Measured on 2016-12-19 16:19:57.298874 UTC
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 3 × 3
#> w.length s.e.irrad id
#> <dbl> <dbl> <chr>
#> 1 541. 0.328 fwhm
#> 2 604. 0.657 peak
#> 3 661. 0.330 fwhm
