From 121c4af1db7d1bd0bc103dec7cdecf1b152611ee Mon Sep 17 00:00:00 2001 From: shinigami-777 Date: Fri, 20 Mar 2026 00:43:53 +0530 Subject: [PATCH] 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 -----------------------------------------------------------------