r - R中的重复测量方差分析:必须使用有效的下标向量子集列
问题描述
237 名参与者全部完成了 4 个实验条件,这些条件由变量 A、B 的两个水平(YesxLow、Yes x High、No x Low、No x High)描述。
我正在尝试进行重复测量方差分析,以识别 4 个不同组中得分平均值的差异,R 中的 A x B 使用以下函数:
res.aov <- anova_test(
data = my.data, dv = my.data$Score, wid = my.data$id,
within = c(my.data$A, my.data$B)
)
get_anova_table(res.aov)
但我不断收到以下错误:
错误:必须使用有效的下标向量对列进行子集化。x 由于精度损失,无法从 to 转换。
调试信息:
> x
+-<error/vctrs_error_subscript_type>
| Must subset columns with a valid subscript vector.
| x Can't convert from <double> to <integer> due to loss of precision.
\-<error/vctrs_error_cast_lossy>
Can't convert from <double> to <integer> due to loss of precision.
Backtrace:
x
1. +-rstatix::anova_test(...)
2. | \-`%>%`(...)
3. | +-base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
5. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
6. | \-rstatix:::`_fseq`(`_lhs`)
7. | \-magrittr::freduce(value, `_function_list`)
8. | \-function_list[[i]](value)
9. | \-rstatix:::select_quo_variables(., data)
10. | \-rstatix:::get_quo_vars_list(data, .enquos)
11. | \-.enquos %>% map(~get_quo_vars(data, .))
12. | +-base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
13. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
14. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
15. | \-rstatix:::`_fseq`(`_lhs`)
16. | \-magrittr::freduce(value, `_function_list`)
17. | +-base::withVisible(function_list[[k]](value))
18. | \-function_list[[k]](value)
19. | \-purrr::map(., ~get_quo_vars(data, .))
20. | \-rstatix:::.f(.x[[i]], ...)
21. | \-rstatix:::get_quo_vars(data, .)
22. | \-names(data) %>% tidyselect::vars_select(!!vars) %>% magrittr::set_names(NULL)
23. | +-base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
24. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
25. | \-base::eval(quote(`_fseq`(`_lhs`)), env, env)
26. | \-rstatix:::`_fseq`(`_lhs`)
27. | \-magrittr::freduce(value, `_function_list`)
28. | \-function_list[[i]](value)
29. | \-tidyselect::vars_select(., !!vars)
30. | \-tidyselect:::eval_select_impl(...)
31. | +-tidyselect:::with_subscript_errors(...)
32. | | +-base::tryCatch(...)
33. | | | \-base:::tryCatchList(expr, classes, parentenv, handlers)
34. | | | \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
35. | | | \-base:::doTryCatch(return(expr), name, parentenv, handler)
36. | | \-tidyselect:::instrument_base_errors(expr)
37. | | \-base::withCallingHandlers(...)
38. | \-tidyselect:::vars_select_eval(...)
39. | \-tidyselect:::walk_data_tree(expr, data_mask, context_mask)
40. | \-tidyselect:::eval_c(expr, data_mask, context_mask)
41. | \-tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
42. | \-tidyselect:::walk_data_tree(new, data_mask, context_mask)
43. | \-tidyselect:::as_indices_sel_impl(...)
44. | \-tidyselect:::as_indices_impl(x, vars, strict = strict)
45. | \-vctrs::vec_as_subscript(x, logical = "error")
46. \-vctrs:::try_catch_impl(...)
47. +-base::tryCatch(try_catch_callback(data, NULL), ...)
48. | \-base:::tryCatchList(expr, classes, parentenv, handlers)
49. | \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
50. | \-base:::doTryCatch(return(expr), name, parentenv, handler)
51. \-vctrs:::try_catch_callback(data, NULL)
52. \-(function () ...
53. \-vctrs:::vec_cast.integer.double(...)
54. \-vctrs::maybe_lossy_cast(out, x, to, lossy, x_arg = x_arg, to_arg = to_arg)
55. +-base::withRestarts(...)
56. | \-base:::withOneRestart(expr, restarts[[1L]])
57. | \-base:::doWithOneRestart(return(expr), restart)
58. \-vctrs:::stop_lossy_cast(...)
59. \-vctrs:::stop_vctrs(...)
我试图将这些因素转换为数值变量,但我仍然得到同样的错误。知道可能出了什么问题吗?
解决方案
以下似乎解决了这个问题:
res.aov <- anova_test(
data = my.data, dv = Score, wid = id,
within = c(A,B)
)
get_anova_table(res.aov)
推荐阅读
- node.js - 按字段 1 聚合组并计算字段 2 的总和
- mongodb - Mongoose $lookup 未按预期响应
- tensorflow - 训练模型上的 TensorFlow 错误(在 GPU 上)
- sql - 视图的自动源到目标列映射 - SQL Server
- css - Woocommerce:产品类别小部件
- excel - 在 Excel Desktop 中创建和设置时,Office.Settings 无法在 Excel Online 中检索
- python - + 和 | 有什么区别?添加到另一个变量时?
- java - WebLogic Server 中的 Firebase FCM 问题
- swift - 嵌入式导航链接
- amazon-web-services - 如何拉取 AWS Lambda 容器镜像