diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 34a7b02d1..12e34dea1 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -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.") diff --git a/src/transpose.c b/src/transpose.c index 1ae859e20..14e0d1f08 100644 --- a/src/transpose.c +++ b/src/transpose.c @@ -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 : {