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.
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.