我正试图在以下数据帧上重复测量Anova:
> 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…
我使用以下代码来运行anova:
summary(aov(key_resp.rt~target_onset+Error(participant/target_onset)), data=data_clean)
然而,我得到以下错误:
eval(predvars,data,env(中的错误:找不到对象"key_resp.rt">
我不知道为什么它不将该列识别为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"))