Part 3: improve consistency with as.factor() / as.character() conversion
pssachdeva opened this issue · 2 comments
pssachdeva commented
At some points in the lesson, it appears that conversions from characters to factors are done, or vice versa. These are not done consistently. The default import does not convert the characters in the dataframe to factors, but later code blocks assume that these columns were already factors. They should be made consistent.
It is probably best to import the dataframes with stringsAsFactors = TRUE
, and then make sure every conversion thereafter makes sense.
asteves commented
As of R 4.0.0, this is the default behavior for data import as well in base R.
asteves commented
Looking at this again, my previous comment was not clear. The default behavior in R 4.0.0 and onwards is that stringsAsFactors = FALSE.