R中的重复测量方差分析:必须具有有效下标向量的子集列

问题描述

我有一个类似于以下内容的数据集:

enter image description here

237位参与者全部​​完成了4个实验条件,分别由变量A,B的两个级别描述(YesxLow,Yes x高,No x Low,No x高)。 我正在尝试进行一种重复测量方差分析,以使用以下功能来识别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由于精度下降而无法从转换为。

调试信息:

> 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)
  5. |     \-base::eval(quote(`_fseq`(`_lhs`)),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))
 13. |                   \-base::eval(quote(`_fseq`(`_lhs`)),env)
 14. |                     \-base::eval(quote(`_fseq`(`_lhs`)),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))
 24. |                                     \-base::eval(quote(`_fseq`(`_lhs`)),env)
 25. |                                       \-base::eval(quote(`_fseq`(`_lhs`)),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,handlers[[1L]])
 35. |                                                   | |     \-base:::doTryCatch(return(expr),name,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,context_mask)
 41. |                                                         \-tidyselect:::reduce_sels(node,context_mask,init = init)
 42. |                                                           \-tidyselect:::walk_data_tree(new,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,handlers)
 49.   |   \-base:::tryCatchOne(expr,handlers[[1L]])
 50.   |     \-base:::doTryCatch(return(expr),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)