swcarpentry / r-novice-gapminder

R for Reproducible Scientific Analysis
http://swcarpentry.github.io/r-novice-gapminder/
Other
164 stars 538 forks source link

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

Closed sarakyeo closed 1 year ago

sarakyeo commented 1 year ago

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

matthieu-bruneaux commented 1 year ago

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 :smiley: We will close this issue if the PR solves it adequately.

matthieu-bruneaux commented 1 year ago

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