gpt4 book ai didi

error-handling - 如何修复错误 : Subscript `AMr1.orig` is a matrix, 数据 `x.imp[, -possibleFactors][AMr1.orig]` 的大小必须为 1

转载 作者:行者123 更新时间:2023-12-03 08:17:46 29 4
gpt4 key购买 nike

我正在尝试运行 Amelia 以使用以下代码在多个变量上估算一些缺失数据:

set.seed(1)zz[,c("id", "sex", "team", "minsSocial", "satisTravail", "performance")] <-Amelia::amelia(zz[,c("id", "sex", "team", "minsSocial", "satisTravail", "performance")],m=1, idvars="id", noms=c("sex","team"))$imputations$imp1

很遗憾,我收到此错误消息:

Erreur : 下标 AMr1.orig 是一个矩阵,数据 x.imp[, -possibleFactors][AMr1.orig] 的大小必须为 1。

关于问题出在哪里以及如何解决问题的任何问题?是不是因为我的数据包含值 <1?

谢谢!

最佳答案

我认为这可能是由于最近对小标题中的错误处理进行了一些更改。如果您将数据转换为 data.frame(假设 zz 是 tibble),错误应该会消失(这对我有用)。

zz <- as.data.frame(zz)

但不确定错误消息背后的原因。我从 rlang::last_error() 收到了类似的错误消息,并且代码适用于早期版本的包。

<error/tibble_error_subset_matrix_must_be_scalar>
Subscript `AMr1.orig` is a matrix, the data `x.imp[AMr1.orig]` must have size 1.
Backtrace:
1. Amelia::amelia(...)
2. Amelia::amelia.default(...)
3. base::lapply(seq_len(m), do.amelia)
4. Amelia:::FUN(X[[i]], ...)
5. Amelia:::impfill(...)
7. tibble:::`[<-.tbl_df`(...)
8. tibble:::tbl_subassign_matrix(x, j, value, j_arg, substitute(value))

关于error-handling - 如何修复错误 : Subscript `AMr1.orig` is a matrix, 数据 `x.imp[, -possibleFactors][AMr1.orig]` 的大小必须为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64056125/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com