Skip to contents

Return subsets of spectra stored in class generic_spct or derived from it.

Usage

# S3 method for class 'generic_spct'
subset(x, subset, select, drop = FALSE, ...)

Arguments

x

object to be subsetted.

subset

logical expression indicating elements or rows to keep: missing values are taken as false.

select

expression, indicating columns to select from a spectrum.

drop

passed on to [ indexing operator.

...

further arguments to be passed to or from other methods.

Value

An object similar to x containing just the selected rows and columns. Depending on the columns remaining after subsetting the class of the object will be simplified to the most derived parent class.

Note

This method is copied from base::subset.data.frame() but ensures that all metadata stored in attributes of spectral objects are copied to the returned value.

Examples


subset(sun.spct, w.length > 400)
#> Object: source_spct [400 x 3]
#> Wavelength range 401-800 nm, step 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: 400 × 3
#>    w.length s.e.irrad  s.q.irrad
#>       <dbl>     <dbl>      <dbl>
#>  1      401     0.626 0.00000210
#>  2      402     0.650 0.00000218
#>  3      403     0.621 0.00000209
#>  4      404     0.637 0.00000215
#>  5      405     0.626 0.00000212
#>  6      406     0.600 0.00000204
#>  7      407     0.595 0.00000202
#>  8      408     0.626 0.00000213
#>  9      409     0.662 0.00000226
#> 10      410     0.561 0.00000192
#> # ℹ 390 more rows