4

Fixing a new problem in some DBDA2E scripts caused by a change in R 4.0.0

 3 years ago
source link: http://doingbayesiandataanalysis.blogspot.com/2020/09/fixing-new-problem-in-some-dbda2e.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fixing a new problem in some DBDA2E scripts caused by a change in R 4.0.0

The scripts that accompany DBDA2E have worked fine, "out of the box," for years. But recently some scripts have had problems. Why? R has changed. With R 4.0.0, various functions such as read.csv() no longer automatically convert strings to factors. Some DBDA2E scripts assumed the results of those functions contained factors, but if you're now using R 4.0.0 (or more recent) those scripts will balk. 

So, what to do? Here's a temporary fix. When you open your R session, type in this global option:

options(stringsAsFactors = TRUE)

Unfortunately this option will eventually be deprecated. I'll have to modify every affected script and post updated versions. This will happen someday. I hope.

Why did R change? You can read about it here: 

https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK