From 121c4af1db7d1bd0bc103dec7cdecf1b152611ee Mon Sep 17 00:00:00 2001 From: shinigami-777 Date: Fri, 20 Mar 2026 00:43:53 +0530 Subject: [PATCH 1/2] convert label<- to s4 generic function Signed-off-by: shinigami-777 --- R/labels.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/R/labels.R b/R/labels.R index c9211b93..2c170a66 100644 --- a/R/labels.R +++ b/R/labels.R @@ -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) @@ -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 ----------------------------------------------------------------- From 1f3a658252caa186863c9cd43345954b357df014 Mon Sep 17 00:00:00 2001 From: Tamaghna Chattopadhyay <139495942+shinigami-777@users.noreply.github.com> Date: Fri, 26 Jun 2026 09:22:33 +0530 Subject: [PATCH 2/2] added change to NEWS.md --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index ce22ec59..b6b41acc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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