Learn R Programming

photobiology (version 0.11.3)

setIdFactor: Set the "idfactor" attribute

Description

Function to set, rename or unset by reference the "idfactor" attribute of an existing object of class generic_spct or an object of a class derived from generic_spct.

Usage

setIdFactor(x, idfactor)

id_factor(x) <- value

Value

x

Arguments

x

a generic_spct object.

idfactor, value

character The name of a factor identifying multiple spectra stored longitudinally.

Details

If the attribute idfactor is already set, and a variable with name equal to the value passed as argument to idfactor does not exist in x, the currently set variable is renamed and the attribute value updated. If a variable named as the argument passed to idfactor exists in x, it will be set as id by storing this name in the attribute. If the value passed as argument to idfactor is NULL the attribute will be unset. If the attribute is not already set and there is no member variable in x with a name matching the argument passed to idfactor, an error is triggered.

See Also

Other idfactor attribute functions: getIdFactor()

Examples

Run this code
my.spct <- sun_evening.spct

# inspecting
id_factor(sun.spct) # no idfactor set

id_factor(my.spct)
colnames(my.spct)

# renaming
id_factor(my.spct) <- "time"
getIdFactor(my.spct)
colnames(my.spct)

# removing
setIdFactor(my.spct, NULL)
getIdFactor(my.spct)
colnames(my.spct)

Run the code above in your browser using DataLab