From 037c3b023491671ef13d034fbaeaa0b08966a571 Mon Sep 17 00:00:00 2001 From: Dom Jarkey Date: Fri, 9 Sep 2022 17:35:13 +0100 Subject: [PATCH] Ensure factors become large factors objects (this drastically speeds up summary statistics --- R/codeBookGeneric.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/codeBookGeneric.R b/R/codeBookGeneric.R index 7b4de8a..7aa33fe 100644 --- a/R/codeBookGeneric.R +++ b/R/codeBookGeneric.R @@ -101,6 +101,9 @@ writeCodeBookLatexGeneric <- function( if (cls == "integer") { x <- as.integer(as.numeric(x)) } + if (cls == "factor") { + x <- factor(levels(x)[as.integer(x)], levels = levels(x)) + } } } else {