Post #1762595
2024-10-20 03:54 UTC
Today I (eventually) learned while investigating student code that lm(), but not glm(), will silently convert a character response variable to numeric. 😐
#rstats
Replies (3)
-
@LeoRJorge@mastodon.social 2024-10-20 06:27
@tslumley@fediscience.org not sure what to make of it, given lm works only with numeric responses but glm accepts categorical responses. It's still a bit weird that lm doesn't even give you a warning that it converted the variable
-
@JorisMeys@mstdn.social 2024-10-20 09:27
@tslumley@fediscience.org eh... didn't expect that.
-
@nxskok@mastodon.cloud 2024-10-21 01:11
what just happened for me is that converting a character variable to numeric via as.numeric produced a vector of NAs, and a complaint from lm when I used the original character variable as a response that it had NA or NaN or Inf in it, which does seem to be consistent with what you said.