QCBSRworkshops / workshop04

Workshop 4 - Linear models
https://r.qcbs.ca/workshops/r-workshop-04/
Other
9 stars 53 forks source link

data.frame() no longer converts strings columns to factors #4

Closed KevCaz closed 3 years ago

KevCaz commented 3 years ago

Since R v4.0.0, strings are no longer automatically converted to factors. As a consequence when importing data with functions such as read.csv(), e.g.

bird <- read.csv("data/birdsdiet.csv")

2 different behaviors for R 3.6. and R 4.0. are expected (which is the reason why Travis is currently failing). To avoid this, stringsAsFactors should be specified, e.g.

bird <- read.csv("data/birdsdiet.csv", stringsAsFactors = TRUE)

Once the changes are done, the script works with both R<3.6. AND R>4.0..