I am working with an S4 Hyperspec Object in R composed of wavelengths and corresponding different absorbance spectra datasets. I would like to select a wavelength and print out the corresponding absorbance per specific spectra.
But I'm not sure how to go about doing that.
Any advice?
I'm not super knowledgeable about object-oriented programming...
Thank you!
You can use @
or slot
:
#define new s4 class
myS4Class <- setClass(
"myS4Class",
slots = c(
slot1 = "character",
slot2 = "numeric"
)
)
#make an instance of the class
x <- new("myS4Class", slot1 = "foo", slot2 = rnorm(5))
x
can now be indexed as below:
x@slot1
#> [1] "foo"
slot(x, "slot2")
#> [1] 0.2391963 -0.3398150 2.1760187 1.1890521 -0.1659958
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.