Skip to content

Commit 4bdf9d0

Browse files
authored
Merge pull request #796 from SebKrantz/development
Fixes #794
2 parents 569a4a5 + 7ac7871 commit 4bdf9d0

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: collapse
22
Title: Advanced and Fast Data Transformation
3-
Version: 2.1.3.9000
4-
Date: 2025-08-19
3+
Version: 2.1.4
4+
Date: 2025-10-22
55
Authors@R: c(
66
person("Sebastian", "Krantz", role = c("aut", "cre"),
77
email = "[email protected]",

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# collapse 2.1.3.9000
1+
# collapse 2.1.4
22

33
* *collapse* now has a custom internal version of `unlist()` with better attribute preservation capabilities and a slight speed improvement. Thanks @aidanhorn (#785).
44

5+
* Fixes (#794) -- thanks @kendonB for reporting and making an effort to create a reprex.
6+
57
# collapse 2.1.3
68

79
* Various bug fixes (#769, #772 and #779).

R/descr.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ print_descr_default <- function(x, n = 14, perc = TRUE, digits = 2, t.table = TR
300300
t <- unclass(xi[[4L]])
301301
if(length(t) <= n) {
302302
if(perc) print.default(cb(t, round(t/bsum(t)*100, digits)), right = TRUE, print.gap = 2, quote = FALSE) else
303-
print.table(ct(t))
303+
print.table(ct(t), digits = digits)
304304
} else {
305305
t1 <- t[seq_len(n)]
306306
st <- bsum(t)
@@ -310,7 +310,7 @@ print_descr_default <- function(x, n = 14, perc = TRUE, digits = 2, t.table = TR
310310
print.default(cb(c(t1, rem), round(c(pct, 100-bsum(pct)), digits)), right = TRUE, print.gap = 2, quote = FALSE)
311311
# cat("...\n")
312312
} else {
313-
print.table(ct(c(t1, rem)))
313+
print.table(ct(c(t1, rem)), digits = digits)
314314
# cat("...\n")
315315
}
316316
if(summary) {
@@ -398,7 +398,7 @@ print_descr_grouped <- function(x, n = 14, perc = TRUE, digits = 2, t.table = TR
398398
if(perc) pct <- tab %r/% st * 100 # dimnames(tab)[[2L]] <- paste0(dimnames(tab)[[2L]], "\nFreq Perc")
399399
}
400400
if(perc) {
401-
tab <- duplAttributes(paste(tab, format(pct, digits = digits, justify = "right")), tab)
401+
tab <- duplAttributes(paste(format(tab, digits = digits, justify = "right"), format(pct, digits = digits, justify = "right")), tab)
402402
print.default(if(t.table) tab else t(tab), right = TRUE, print.gap = 2, quote = FALSE)
403403
} else print.table(if(t.table) tab else t(tab), digits = digits)
404404
if(summary && nrow(t) > n) {

src/fmean.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,14 +577,15 @@ SEXP fmeanlC(SEXP x, SEXP Rng, SEXP g, SEXP gs, SEXP w, SEXP Rnarm, SEXP Rdrop,
577577
if(ATTRIB(xj) != R_NilValue && !(isObject(xj) && inherits(xj, "ts"))) copyMostAttrib(xj, outj);
578578
if(TYPEOF(xj) != REALSXP) {
579579
if(TYPEOF(xj) != INTSXP && TYPEOF(xj) != LGLSXP) error("Unsupported SEXP type: '%s'", type2char(TYPEOF(xj)));
580-
if(dup == 0) {x = PROTECT(shallow_duplicate(x)); ++nprotect; px = SEXPPTR_RO(x); dup = 1;}
580+
if(dup == 0) {x = PROTECT(shallow_duplicate(x)); ++nprotect; dup = 1;}
581581
SET_VECTOR_ELT(x, j, coerceVector(xj, REALSXP));
582+
px = SEXPPTR_RO(x); // Fix suggested by ChatGPT
582583
}
583584
}
584585
#pragma omp parallel for num_threads(nthreads)
585586
for(int j = 0; j < l; ++j) fmean_weights_g_impl(REAL(pout[j]), REAL(px[j]), ng, pg, pw, narm, nrx);
586587
} else {
587-
for(int j = 0; j != l; ++j) pout[j] = fmean_wg_impl(px[j], ng, pg, pw, narm);
588+
for(int j = 0; j != l; ++j) SET_VECTOR_ELT(out, j, fmean_wg_impl(px[j], ng, pg, pw, narm));
588589
}
589590
}
590591
}

src/fsum.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,15 @@ SEXP fsumlC(SEXP x, SEXP Rng, SEXP g, SEXP w, SEXP Rnarm, SEXP fill, SEXP Rdrop,
680680
if(ATTRIB(xj) != R_NilValue && !(isObject(xj) && inherits(xj, "ts"))) copyMostAttrib(xj, outj);
681681
if(TYPEOF(xj) != REALSXP) {
682682
if(TYPEOF(xj) != INTSXP && TYPEOF(xj) != LGLSXP) error("Unsupported SEXP type: '%s'", type2char(TYPEOF(xj)));
683-
if(dup == 0) {x = PROTECT(shallow_duplicate(x)); ++nprotect; px = SEXPPTR_RO(x); dup = 1;}
683+
if(dup == 0) {x = PROTECT(shallow_duplicate(x)); ++nprotect; dup = 1;}
684684
SET_VECTOR_ELT(x, j, coerceVector(xj, REALSXP));
685+
px = SEXPPTR_RO(x); // Fix suggested by ChatGPT
685686
}
686687
}
687688
#pragma omp parallel for num_threads(nthreads)
688689
for(int j = 0; j < l; ++j) fsum_weights_g_impl(REAL(pout[j]), REAL(px[j]), ng, pg, pw, narm, nrx);
689690
} else {
690-
for(int j = 0; j != l; ++j) pout[j] = fsum_wg_impl(px[j], ng, pg, pw, narm);
691+
for(int j = 0; j != l; ++j) SET_VECTOR_ELT(out, j, fsum_wg_impl(px[j], ng, pg, pw, narm));
691692
}
692693
}
693694
}

0 commit comments

Comments
 (0)