Reputation: 3
I am trying to do some data analysis for a statistics assignment. And when I try to look at a summary of my data, the categorical variables do not display correctly. This is what I see when I run my code:
vs what is shown when my lecturer runs the same code:
This is the code that I am using, copied directly from my lecturers notes.
stormwater <- read.csv("stormwater example Milandri et al.csv")
head(stormwater)
tail(stormwater)
summary(stormwater)
Upvotes: 0
Views: 782
Reputation: 388982
The difference comes because of different R versions. You are on R 4.0.0 (or higher) where stringsAsFactors
default value is changed to FALSE
so all your string data is read as characters instead of factors which was default in previous versions.
You should get the same result as your lecturer if you add stringsAsFactors = TRUE
in your read.csv
command.
stormwater <- read.csv("stormwater example Milandri et al.csv", stringsAsFactors = TRUE)
summary(stormwater)
Upvotes: 1