swcarpentry/r-novice-gapminder

Adding newRow in Exploring Data Frames does not result in error message

Closed this issue · 2 comments

I selected the Exploring Data Frames episode for my Carpentries Instructor Training teaching demonstration. As I was preparing for the participatory live coding, I noticed that adding the object newRow to the cats data frame did not result in the warning message (see attached image) noted in the episode because cats$coat is not a factor (it is chr instead).

I could not find in previous episodes where this was changed to a factor instead of character data. It may be confusing for learners to _not _ get the warning message that they expect. This also means that the NA value does not show up in cats after adding newRow to the data frame.

cats-newrow

Thank you very much for noticing this @sarakyeo! This is very helpful.

We probably missed this when we updated various parts of the lesson to use characters instead of factors in order to match the new default behaviour in R >= 4.0.0 (where stringsAsFactors is no longer TRUE by default when loading data or building data frames).

It turns out there is currently an open PR (#829) related to that, which is nice timing 😃 We will close this issue if the PR solves it adequately.

Solved by merging PR #829. Thank you @sarakyeo and @hannaheow!