The R scripts that accompany DBDA2E have been updated so they work with R 4.1. Please go to the book's software page at
https://sites.google.com/site/doingbayesiandataanalysis/software-installation
and scroll down to the bottom of that page to find the link to the zip file for the updated scripts.
I changed some scripts that use the R function read.csv() and relied on the old default of casting string vectors as factors. The default was changed in R 4.0, and the global option stringsAsFactors=TRUE no longer works for read.csv() in R 4.1.