Select extra data columns from the hyperSpec object. Special column $spc contains the spectra matrix. If $spc is dropped, the result is a data.frame instead of a hyperSpec object. Convert the data.frame again into a hyperSpec object if needed by using as.hyperSpec ().

# S3 method for hyperSpec
select(.data, ...)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.

...

<tidy-select> One or more unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables.

Value

hyperSpec object or data.frame with the selected columns. If the $spc is not included in the selection, the result will be a data.frame.

Details

Wavelength selection is not yet provided. #is done separately by select_wl().

See also

Examples


chondro %>%
  select(x, y, clusters) %>%
  head() # spc not selected => data.frame
#>        x     y clusters
#> 1 -11.55 -4.77   matrix
#> 2 -10.55 -4.77   matrix
#> 3  -9.55 -4.77   matrix
#> 4  -8.55 -4.77   matrix
#> 5  -7.55 -4.77   matrix
#> 6  -6.55 -4.77   matrix
chondro %>% select(x, clusters, spc) # => hyperSpec object
#> hyperSpec object
#>    875 spectra
#>    3 data columns
#>    300 data points / spectrum

chondro %>%
  select(-spc) %>%
  head() # all columns but $spc => data.frame same as chondro$..
#>       y      x            filename clusters
#> 1 -4.77 -11.55 rawdata/chondro.txt   matrix
#> 2 -4.77 -10.55 rawdata/chondro.txt   matrix
#> 3 -4.77  -9.55 rawdata/chondro.txt   matrix
#> 4 -4.77  -8.55 rawdata/chondro.txt   matrix
#> 5 -4.77  -7.55 rawdata/chondro.txt   matrix
#> 6 -4.77  -6.55 rawdata/chondro.txt   matrix
chondro %>%
  select(-spc) %>%
  as.hyperSpec() # hyperSpec object with 0 wavelengths
#> hyperSpec object
#>    875 spectra
#>    5 data columns
#>    0 data points / spectrum