簡體   English   中英

R中的重復測量方差分析:必須使用有效的下標向量對列進行子集

[英]Repeated Measures ANOVA in R : Must subset columns with a valid subscript vector

我有一個類似於以下的數據集:
在此處輸入圖片說明

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM