A serious design flaw in S/R means that your code fails badly and silently. The man page suggests that you try as.numeric(factor(5:10)).
Matt Simpson’s code is correct. The man page suggests slightly faster as.numeric(levels(dat$IQTest))[dat$IQTest]. That example also shows why they chose the the coercion that they did.
“iqt ← as.numeric(dat$IQTest)” The already numeric IQ is in dat$IQ, iqt is only the suspect, online IQtest.
A serious design flaw in S/R means that your code fails badly and silently. The man page suggests that you try as.numeric(factor(5:10)).
Matt Simpson’s code is correct. The man page suggests slightly faster as.numeric(levels(dat$IQTest))[dat$IQTest]. That example also shows why they chose the the coercion that they did.