Anova 公式无法识别我的列标题

Anova formula not recognizing my column heading

我正在尝试对以下数据框进行 repeated-measures 方差分析:

> glimpse(data_clean)
Rows: 8,450
Columns: 6
Groups: participant [27]
$ participant  <dbl> 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1…
$ trial_num    <int> 8, 9, 10, 11, 15, 17, 21, 22, 24, 25, 26, 27, 28, 30, 32, 34, 38, 39, 41,…
$ type         <chr> "gap", "gap", "overlap", "gap", "gap", "gap", "overlap", "gap", "gap", "g…
$ target_onset <chr> "0.4", "0.1", "0", "0.2", "0.1", "0.2", "0", "0.3", "0.2", "0.1", "0.1", …
$ key_resp.rt  <dbl> 0.3260000, 0.3380001, 0.4480000, 0.3940001, 0.3980000, 0.4990001, 0.39800…
$ central_size <dbl> 0.15, 0.15, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0…

我正在使用以下代码 运行 方差分析:

summary(aov(key_resp.rt~target_onset+Error(participant/target_onset)), data=data_clean)

但是,我收到以下错误:

Error in eval(predvars, data, env) : object 'key_resp.rt' not found

我不知道为什么它不将该列识别为我在 data_clean 中的 dv。任何建议表示赞赏。谢谢

问题是 aov 的右括号在 data = 之前被触发。因此,它直接在全局环境中搜索 'key_resp.rt' 对象,而不是未创建对象的 'data' 环境,从而导致错误

summary(aov(key_resp.rt ~ target_onset + Error(participant/target_onset), 
     data = data_clean))

-输出

#Error: participant:target_onset
#             Df   Sum Sq  Mean Sq
#target_onset  2 0.009603 0.004801

数据

data_clean <- structure(list(participant = c(1010, 1010, 1010), ttrial_num = c(8, 
9, 10), type = c("gap", "gap", "overlap"), target_onset = c("0.4", 
"0.1", "0"), key_resp.rt = c(0.32, 0.338, 0.448)), row.names = c(NA, 
-3L), class = c("tbl_df", "tbl", "data.frame"))