ANOVA: Degrees of freedom almost all equal 1

∥☆過路亽.° 提交于 2019-12-01 04:37:34

R determines whether it should treat variables as categorical (ANOVA-type analysis) or continuous (regression-type analysis) by checking whether they are numeric or factor variables. Most simply, you can convert your predictor (independent) variables to factors via

facs <- c("R","N","P")
d.weight[facs] <- lapply(d.weight[facs],factor) 

If you want to create auxiliary variables instead of overwriting you could do something like

for (varname in facs) {
   d.weight[[paste0("f",varname)]] <- factor(d.weight[[varname]])
}

There might be a more compact way to do it but that should serve ...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!