From 74f41571b0f82cf8a46e4f782a0dad148d09df29 Mon Sep 17 00:00:00 2001 From: Elio Campitelli Date: Fri, 9 Jun 2023 11:20:50 -0300 Subject: [PATCH] Removes attributes and classes only of affected columns --- R/unperiodic.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/unperiodic.R b/R/unperiodic.R index 3a58bf6..2c63167 100644 --- a/R/unperiodic.R +++ b/R/unperiodic.R @@ -34,14 +34,14 @@ unperiodic.periodic_df <- function(object, ...) { } for (i in seq_along(cols)) { - data.table::setattr(object[[cols[i]]], "period", NULL) - data.table::setattr(object[[cols[i]]], "class", class(object[[cols[i]]])[class(object[[cols[i]]]) != "sticky"]) - data.table::setattr(object, "class", class(object)[class(object) != "periodic_df"]) - - # class(object[[cols[i]]]) <- class(object[[cols[i]]])[class(object[[cols[i]]]) != "sticky"] - # class(object) <- class(object)[class(object) != "periodic_df"] + if (inherits(object[[cols[i]]], "sticky")) { + data.table::setattr(object[[cols[i]]], "period", NULL) + data.table::setattr(object[[cols[i]]], "class", setdiff(class(object[[cols[i]]]), "sticky")) + } } + data.table::setattr(object, "class", setdiff(class(object), "periodic_df")) + # browser() if (.should.copy(object)) { return(object) } else {