csgillespie / efficientR

Efficient R programming: a book
https://csgillespie.github.io/efficientR/
Other
719 stars 375 forks source link

2.4.5 stringsAsFactors=FALSE verbiage outdated? #269

Open engineerchange opened 4 years ago

engineerchange commented 4 years ago

Currently, 2.4.5 references options(stringsAsFactors=FALSE) as a .Rprofile preset that can make code less portable. R 4.0.0 made stringsAsFactors=FALSE the default behavior, so recommend re-write or suggest different non-portable example in .Rprofile file.

Snippet:

Try to avoid adding options to the start-up file that make your code non-portable. For example, adding options(stringsAsFactors = FALSE) to your start-up script has knock-on effects for read.table and related functions including read.csv, making them convert text strings into characters rather than into factors as is default. This may be useful for you, but can make your code less portable, so be warned.
Robinlovelace commented 4 years ago

:+1: definitely one we can happily move on from now.

Robinlovelace commented 4 years ago

P.s. if you want to have a 1st bash at a fix for R 4.0.0 PRs are welcome. I plan to get back to this over the weekend if not.

engineerchange commented 4 years ago

Going to add a note that 3.4.1 has similar verbiage re: stringsAsFactors=FALSE default behaviour.

Robinlovelace commented 4 years ago

Awesome, I plan to look at this properly over the weekend.