Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* Dataset `faux_cell` and function `generate_faux_cell()` replace `chondro` dataset (cbeleites/hyperSpec#125, cbeleites/hyperSpec#156, cbeleites/hyperSpec#180, cbeleites/hyperSpec#229).
* Documentation aliases have been updated. Now, ?hyperSpec points to the function `hyperSpec()`, and to refer to the package, `package?hyperSpec` should be used (#129).
* Vignette `hyperSpec.Rmd`: suggested packages (`pls`) are now loaded conditionally so the vignette builds even when they are not installed.
* Function `labels<-()` converted into an S4 generic, making it consistent with the existing `labels()` S4 generic (r-hyperspec/hyperSpec#115).


### Bugfixes
Expand Down
14 changes: 13 additions & 1 deletion R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ hySpc.testthat::test(.labels) <- function() {
#' @examples
#'
#' labels(flu, "c") <- expression("/"("c", "mg / l"))
`labels<-` <- function(object, which = NULL, ..., value) {
# helper function (similar to .labels for the getter)
.labels_replace <- function(object, which = NULL, ..., value) {
assert_hyperSpec(object)
validObject(object)

Expand All @@ -163,6 +164,17 @@ hySpc.testthat::test(.labels) <- function() {
object
}

# generic replacement function
#' @export
setGeneric("labels<-", function(object, which = NULL, ..., value) {
standardGeneric("labels<-")
})

setMethod("labels<-",
signature = signature(object = "hyperSpec"),
.labels_replace
)


# Unit tests -----------------------------------------------------------------

Expand Down
Loading