在Rstudio中想对数据进行方差分析时,出现了报错。
方差分析代码:
aov_beha <-behav %>%
anova_test(
data = ., dv = RT, wid = sub,
within = cond
)
get_anova_table(aov_beha)
报错内容
ERROR: Problem with `mutate()` input `data`.
x Can't subset columns that don't exist.
x Column `sub` doesn't exist.
i Input `data` is `map(.data$data, .f, ...)`.
最初我以为是数据类型的问题,转来转去转了几次后,依然还是报错
> head(behav)
# A tibble: 6 x 4
# Groups: sub [2]
sub cond RT ACC
<int> <int> <dbl> <dbl>
1 1 1 0.311 1
2 1 2 0.256 1
3 1 3 0.317 1
4 1 4 0.305 0.967
5 2 1 0.328 1
6 2 2 0.339 0.967
最后才发现,原来是我之前对数据做了group_by处理。解决办法是,加上ungroup就行了
behav <- od_beha %>%
group_by(sub,cond) %>%
summarise(RT = mean(RT), ACC= mean(ACC)) %>%
ungroup()
ref: r - Error: Can't subset columns that don't exist - Stack Overflow
网友评论