首页 > 解决方案 > 试图进行方差分析

问题描述

所以我试图创建一个方差分析来确定人口变量的独立性。我的数据包含来自 4 个不同地区的多个国家。这是我一直在尝试的:

aov(Region ~ 'Population in thousands (2017)',data = anova.data)

我认为我做对了,但是,每次我得到:

Error in terms.formula(formula, "Error", data = data) : invalid term in model formula

任何帮助将不胜感激。

标签: r

解决方案


aov()期待一个?formula. 除了打字和阅读速度更快之外,这也是为什么通常的做法是使变量名称尽可能短和简单,即没有空格或特殊字符的缩写。

aov(Region ~ `Population in thousands (2017)`, data = df)

# easier
aov(Region ~ Population_in_thousands_2017, data = df)

# easiest
aov(Region ~ pop2017, data = df)

推荐阅读