R: Rescale a spectrum using a summary function

fscale {photobiology} | R Documentation

## Rescale a spectrum using a summary function

### Description

These functions return a spectral object of the same class as the one supplied as argument but with the spectral data rescaled.

### Usage

    fscale(x, ...)

    ## Default S3 method:
    fscale(x, ...)

    ## S3 method for class 'source_spct'
    fscale(x, range = NULL, f = "mean", target = 1,
      unit.out = getOption("photobiology.radiation.unit", default = "energy"),
      ...)

    ## S3 method for class 'response_spct'
    fscale(x, range = NULL, f = "mean", target = 1,
      unit.out = getOption("photobiology.radiation.unit", default = "energy"),
      ...)

    ## S3 method for class 'filter_spct'
    fscale(x, range = NULL, f = "mean", target = 1,
      qty.out = getOption("photobiology.filter.qty", default = "transmittance"),
      ...)

    ## S3 method for class 'reflector_spct'
    fscale(x, range = NULL, f = "mean", target = 1,
      qty.out = NULL, ...)

    ## S3 method for class 'raw_spct'
    fscale(x, range = NULL, f = "mean", target = 1, ...)

    ## S3 method for class 'cps_spct'
    fscale(x, range = NULL, f = "mean", target = 1, ...)

    ## S3 method for class 'generic_spct'
    fscale(x, range = NULL, f = "mean", target = 1,
      col.names, ...)

    ## S3 method for class 'source_mspct'
    fscale(x, range = NULL, f = "mean", target = 1,
      unit.out = getOption("photobiology.radiation.unit", default = "energy"),
      ..., .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'response_mspct'
    fscale(x, range = NULL, f = "mean", target = 1,
      unit.out = getOption("photobiology.radiation.unit", default = "energy"),
      ..., .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'filter_mspct'
    fscale(x, range = NULL, f = "mean", target = 1,
      qty.out = getOption("photobiology.filter.qty", default = "transmittance"),
      ..., .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'reflector_mspct'
    fscale(x, range = NULL, f = "mean", target = 1,
      qty.out = NULL, ..., .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'raw_mspct'
    fscale(x, range = NULL, f = "mean", target = 1, ...,
      .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'cps_mspct'
    fscale(x, range = NULL, f = "mean", target = 1, ...,
      .parallel = FALSE, .paropts = NULL)

    ## S3 method for class 'generic_mspct'
    fscale(x, range = NULL, f = "mean", target = 1,
      col.names, ..., .parallel = FALSE, .paropts = NULL)

    ## Default S3 method:
    fshift(x, ...)

### Arguments

`x` | An R object
`...` | additional named arguments passed down to `f`.
`range` | An R object on which `range()` returns a numeric vector of length 2 with the limits of a range of wavelengths in nm, with min and max wavelengths (nm)
`f` | character string "mean" or "total" for scaling so that this summary value becomes 1 for the returned object, or the name of a function taking `x` as first argument and returning a numeric value.
`target` | numeric A constant used as target value for scaling.
`unit.out` | character Allowed values "energy", and "photon", or its alias "quantum"
`qty.out` | character Allowed values "transmittance", and "absorbance"
`col.names` | character vector containing the names of columns or variables to which to apply the scaling.
`.parallel` | if TRUE, apply function in parallel, using parallel backend provided by foreach
`.paropts` | a list of additional options passed into the foreach function when parallel computation is enabled. This is important if (for example) your code relies on external data or packages: use the .export and .packages arguments to supply them so that all cluster nodes have the correct environment set up for computing.

### Value

A copy of `x` with the original spectral data values replaced with rescaled values, and the `"scaled"` attribute set to a list describing the scaling applied.

a new object of the same class as `x`.

a new object of the same class as `x`.

### Methods (by class)

- `default`: Default for generic function

- `source_spct`:

- `response_spct`:

- `filter_spct`:

- `reflector_spct`:

- `raw_spct`:

- `cps_spct`:

- `generic_spct`:

- `source_mspct`:

- `response_mspct`:

- `filter_mspct`:

- `reflector_mspct`:

- `raw_mspct`:

- `cps_mspct`:

- `generic_mspct`:

- `default`: Default for generic function

### See Also

Other rescaling functions: `fshift`, `getNormalized`, `is_normalized`, `is_scaled`, `normalize`, `setNormalized`, `setScaled`

### Examples

    fscale(sun.spct, f = "mean")
    fscale(sun.spct, f = "mean", na.rm = TRUE)
    fscale(sun.spct, f = sum)
    fscale(sun.spct, f = function(x) {sum(x) / length(x)})

[Package photobiology version 0.9.21 Index]