Skip to contents

Create a named list of character strings describing the variables contained in a spectrum object.

Usage

make_var_labels(x, ...)

# Default S3 method
make_var_labels(x, ...)

# S3 method for class 'source_spct'
make_var_labels(x, ...)

# S3 method for class 'response_spct'
make_var_labels(x, ...)

# S3 method for class 'filter_spct'
make_var_labels(x, ...)

# S3 method for class 'reflector_spct'
make_var_labels(x, ...)

# S3 method for class 'object_spct'
make_var_labels(x, ...)

# S3 method for class 'solute_spct'
make_var_labels(x, ...)

# S3 method for class 'chroma_spct'
make_var_labels(x, ...)

# S3 method for class 'calibration_spct'
make_var_labels(x, ...)

# S3 method for class 'raw_spct'
make_var_labels(x, ...)

# S3 method for class 'cps_spct'
make_var_labels(x, ...)

Arguments

x

An object of a class derived from generic_spct.

...

Currently ignored.

Value

A named list of character strings with one member for each recognized column in x. This list can be used to set variable labels with methods from package 'labelled'. However, package 'photobiology' does not natively support variable labels stored in attribute label.

Details

Objects of classes derived from generic_spct are used to store different types of spectral data. The data stored in some of the classes needs to be interpreted differently depending on how they were measured or are expressed and this information is stored in attributes of the objects. In other cases, even if consistent across different objects, the units of expression may not be obvious to users. The names of the variables are concise, thus using variable labels makes it possible to make these features visible when exploring the data. The methods provided do not add the labels, only supply the character strings. Variable labels are implemented in packages 'labelled' by setting the label attribute in each variable (= column) of a data frame or tibble. This is compatible with the approach used by package 'haven'.

Methods (by class)

  • make_var_labels(default):

  • make_var_labels(source_spct):

  • make_var_labels(response_spct):

  • make_var_labels(filter_spct):

  • make_var_labels(reflector_spct):

  • make_var_labels(object_spct):

  • make_var_labels(solute_spct):

  • make_var_labels(chroma_spct):

  • make_var_labels(calibration_spct):

  • make_var_labels(raw_spct):

  • make_var_labels(cps_spct):

Note

These methods are still under development and the text of the labels may change. Not all classes derived from generic_spct are yet supported.

Examples

make_var_labels(sun.spct)
#> $w.length
#> [1] "Wavelength [nm]"
#> 
#> $s.e.irrad
#> [1] "Spectral energy irradiance [W m-2 nm-1]"
#> 
#> $s.q.irrad
#> [1] "Spectral photon irradiance [mol s-1 m-2 nm-1]"
#> 
# str() prints more compactly than print()
str(make_var_labels(sun.spct))
#> List of 3
#>  $ w.length : chr "Wavelength [nm]"
#>  $ s.e.irrad: chr "Spectral energy irradiance [W m-2 nm-1]"
#>  $ s.q.irrad: chr "Spectral photon irradiance [mol s-1 m-2 nm-1]"
str(make_var_labels(normalize(sun.spct)))
#> List of 2
#>  $ w.length : chr "Wavelength [nm]"
#>  $ s.e.irrad: chr "Spectral energy irradiance [normalized]"
str(make_var_labels(fscale(sun.spct)))
#> List of 2
#>  $ w.length : chr "Wavelength [nm]"
#>  $ s.e.irrad: chr "Spectral energy irradiance [scaled]"

str(make_var_labels(sun_daily.spct))
#> List of 3
#>  $ w.length : chr "Wavelength [nm]"
#>  $ s.e.irrad: chr "Spectral energy exposure [J d-1 m-2 nm-1]"
#>  $ s.q.irrad: chr "Spectral photon exposure [mol d-1 m-2 nm-1]"

str(make_var_labels(polyester.spct))
#> List of 2
#>  $ w.length: chr "Wavelength [nm]"
#>  $ Tfr     : Named chr "Total spectral transmittance [/1]"
#>   ..- attr(*, "names")= chr "total"
str(make_var_labels(normalize(polyester.spct)))
#> List of 2
#>  $ w.length: chr "Wavelength [nm]"
#>  $ Tfr     : Named chr "Total spectral transmittance [normalized]"
#>   ..- attr(*, "names")= chr "total"
str(make_var_labels(fscale(polyester.spct)))
#> List of 2
#>  $ w.length: chr "Wavelength [nm]"
#>  $ Tfr     : Named chr "Total spectral transmittance [scaled]"
#>   ..- attr(*, "names")= chr "total"

str(make_var_labels(white_led.cps_spct))
#> List of 2
#>  $ w.length: chr "Wavelength [nm]"
#>  $ cps     : chr "Detector counts [number s-1]"
str(make_var_labels(white_led.raw_spct))
#> List of 4
#>  $ w.length: chr "Wavelength [nm]"
#>  $ counts_1: chr "Raw detector counts [number]"
#>  $ counts_2: chr "Raw detector counts [number]"
#>  $ counts_3: chr "Raw detector counts [number]"