Learn R Programming

hyperSpec (version 0.95)

initialize: Creating a hyperSpec Object

Description

Like other S4 objects, a hyperSpec object can be created by new. The hyperSpec object is then initialized using the given parameters.

Arguments

.Object
the new hyperSpec object.
data
data.frame, possibly with the spectra in data$spc, and further variates in more columns. A matrix can be entered as one column of a data frame by: data.frame (spc = I (as.matrix (spc))).

Ho

spc
the spectra matrix.

spc does not need to be a matrix, it is converted explicitly by I (as.matrix (spc)).

wavelength
The wavelengths corresponding to the columns of data. If no wavelengths are given, an appropriate vector is derived from the column names of data$spc. If this is not possible, 1 : ncol (data$spc) is
label
A list containing the labels for the columns of the data slot of the hyperSpec object and for the wavelength (in label$.wavelength). The labels should be given in a form ready for the text-dr
log
A list used to fill into the first entry of .Object@log. The elements log$short, log$long, log$date, and log$user are handed down to

Usage

new ("hyperSpec", spc = NULL, data = NULL,

wavelength = NULL, label = NULL, log = NULL)

initialize (.Object, spc = NULL, data = NULL,

wavelength = NULL, label = NULL, log = NULL)

See Also

new for more information on creating and initializing S4 objects. plotmath on expressions for math annotations as for slot label.

Examples

Run this code
new ("hyperSpec")

spc <- matrix (rnorm (12), ncol = 4)
new ("hyperSpec", spc = spc)
new ("hyperSpec", data = data.frame (x = letters[1:3]),
     spc = spc)

colnames (spc) <- 600:603
new ("hyperSpec", spc = spc)  # wavelength taken from colnames (spc)

# given wavelengths precede over colnames of spc
new ("hyperSpec", spc = spc, wavelength = 700:703)

# specifying labels
h <- new ("hyperSpec", spc = spc, data = data.frame (pos = 1 : 3),
          label = list (spc = "I / a.u.",
                        .wavelength = expression (tilde (nu) / cm^-1),
                        pos = expression ("/" (x, mu*m)))
)

plot (h)
plotc (h, use.c = "pos")

# giving a log entry
new ("hyperSpec", log = list (short = "measurement parameters",
     long = list ("exposure / s" = 10, sample = "327a")))

Run the code above in your browser using DataLab