exportRecords without factors leads to bugged redcapFactors
Hi @nutterb,
In a recent experiment I realized that disabling the factors flag in exportRecords results in some unexpected warnings when attributing labels. This leads to NA's appearing during data processing, with a bunch of:
In print.factor(x) : factor levels must be "character"
or
In class(x) <- class(x)[!class(x) %in% c("labelled", "redcapFactor")] :
NAs introduced by coercion
This seems to happen rather late during the export, around here in makeRedcapFactor(). before giving that class, just printing the content of x returns its untouched value. After allocation of this class, it starts failing, with R somehow mistaking it for an actual factor ?
This puzzles me a bit because there's no reason for R to interprete x as a "factor" here.
edit: This may actually be caused by the call to print.factor() in the print.redcapFactor() function. When x is not a factor, obviously print.factor() fails with a warning.