From b769e0182cccf8a785c1396703d25a2979c0421c Mon Sep 17 00:00:00 2001 From: Kyle Husmann Date: Mon, 17 Jun 2024 17:42:11 -0700 Subject: [PATCH] fix stack overflow for display of interlaced cfactors --- R/cfactor.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/R/cfactor.R b/R/cfactor.R index eb9f4ff..a0e03ab 100644 --- a/R/cfactor.R +++ b/R/cfactor.R @@ -208,10 +208,8 @@ as.cfactor.factor <- function(x, codes = NULL, ordered = is.ordered(x)) { #' @importFrom generics as.factor #' @export as.factor.interlacer_cfactor <- function(x, ...) { - if (is.cfactor(x)) { - attr(attr(x, "levels"), "codes") <- NULL - class(x) <- class(x)[-1] - } + attr(attr(x, "levels"), "codes") <- NULL + class(x) <- discard(class(x), \(v) v == "interlacer_cfactor") x } @@ -272,7 +270,7 @@ as.codes.interlacer_cfactor <- function(x, ...) { #' @export print.interlacer_cfactor <- function(x, ...) { if (is.latent.cfactor(x)) { - NextMethod() + obj_print(as.factor(x), ...) } else { obj_print(x, ...) }