Skip to content

Commit

Permalink
add factors test
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schwen committed Dec 7, 2023
1 parent 086a5fd commit c627fad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -6899,6 +6899,7 @@ test(1477.23, transpose(la, list.cols=TRUE), lb)
test(1477.24, transpose(lb, list.cols=TRUE), la)
test(1477.25, transpose(list(list(1L,"a"), list(2L), list(3L,"c")), list.cols=TRUE, fill="b"), la)
test(1477.26, transpose(list(1:2, c("a","b","c")), list.cols=TRUE, fill=3L), lb)
test(1477.27, transpose(list(factor(letters[6:8]), c("a","b","c")), list.cols=TRUE), lb)
test(1477.41, transpose(la, list.cols=NA), error="list.cols should be logical TRUE/FALSE.")


Expand Down
2 changes: 1 addition & 1 deletion src/transpose.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SEXP transpose(SEXP l, SEXP fill, SEXP ignoreArg, SEXP keepNamesArg, SEXP listCo
const int len = length(li);
if (ignore && len==0) continue;
if (TYPEOF(li) != maxtype) {
li = PROTECT(isFactor(li) ? asCharacterFactor(li) : coerceVector(li, maxtype));
li = PROTECT(isFactor(li) && !listCol ? asCharacterFactor(li) : coerceVector(li, maxtype));
} else PROTECT(li); // extra PROTECT just to help rchk by avoiding two counter variables
switch (maxtype) {
case INTSXP : case LGLSXP : {
Expand Down

0 comments on commit c627fad

Please sign in to comment.