Since Adv-R is now knitted with R 4.0, example results in 9.6.1 are no longer giving expected output. Fix: need stringsAsFactors = TRUE
yogat3ch opened this issue · comments
Line 971 in 714f95f
Line 972 in 714f95f
Line 973 in 714f95f
It seems like Adv-R was last re-knitted with R 4.0 because these no longer return an answer that makes sense in the context.
L#971 needs to be updated to have stringsAsFactors = TRUE
df <- data.frame(x = 1:3, y = c("a", "b", "c"), stringsAsFactors = TRUE)
Something similar happens in the first example of section 3.6.1.
The text says that data.frame() converts character vector to factor, but this doesn't happens in the chunk code, probably because now, as @yogat3ch points out, Advance R is knitted with R 4.0
There is also mention of this in section 3.4.1:
In base R you tend to encounter factors very frequently because many base R functions (like
read.csv()
anddata.frame()
) automatically convert character vectors to factors.
There are also a few instances of setting the argument to FALSE
when that is now the default (in addition to those already listed):