`tab_multi_manager()` fails with a named character vector
还没有人认领这个 Issue。
评估
调研方向
问题出在 summarize_secret() 中,其中 var 在 dplyr::rename_with() 内传递给 dplyr::all_of();issue 没有指出源文件或测试。找到该函数,并使用类似 c(variableInteret = "EMPL") 的命名值复现此调用。对于有名称的字符向量,相应列能够无错误地重命名为 VALUE,且现有的无名称输入仍能正常工作,即为完成。
由索引模型根据 Issue 内容生成。
描述
Bug: tab_multi_manager() fails with a named character vector in previously working processing pipelines
Description
A call to tab_multi_manager() fails in summarize_secret() when the value argument is a named character vector rather than an unnamed character string.
This issue did not occur with previous versions: existing processing pipelines that previously ran successfully now fail with the error described below.
For example, cluster[[1]]$nomVarValue may contain:
c(variableInteret = "EMPL")
rather than:
"EMPL"
The names attribute of the vector causes dplyr::rename_with() to fail when var is passed to all_of(var).
Steps to reproduce
liste_tbx_res <- tab_multi_manager(
list_tables = lTables,
list_explanatory_vars = lVars,
alt_hrc = lHrc,
alt_totcode = lTotaux,
value = cluster[[1]]$nomVarValue,
freq = cluster[[1]]$nomVarFreq,
dir_name = file.path(
getOption("rtauargus.tauargus_output"),
sNomcluster
),
cost_var = "cost_var",
secret_no_pl = "secret_no_pl"
)
When cluster[[1]]$nomVarValue is a named character vector, the call fails with the following error:
Error in `purrr::map()`:
i In index: 1.
i With name: ape_EMPL_ceff7.
Caused by error in `dplyr::rename_with()`:
! Can't rename variables in this context.
The error originates from the following code in summarize_secret():
res_tau %>%
{
if (!is.null(var)) {
dplyr::rename_with(., ~ "VALUE", dplyr::all_of(var))
} else {
.
}
}
Expected behavior
The function should continue to accept the named character vectors produced by existing processing pipelines and rename the corresponding column to VALUE without raising an error.
Actual behavior
Processing pipelines that worked with previous versions now fail in dplyr::rename_with() when var retains its names attribute.
Proposed fix
Remove the names attribute before passing var to all_of():
res_tau %>%
{
if (!is.null(var)) {
dplyr::rename_with(., ~ "VALUE", dplyr::all_of(unname(var)))
} else {
.
}
}
Alternatively, normalize var at the beginning of summarize_secret():
if (!is.null(var)) {
var <- unname(var)
}
Additional information
The issue is resolved by passing unname(value) instead of value to summarize_secret(). The underlying variable name ("EMPL") is valid; the problem appears to be related to the vector's names attribute.
This is a regression affecting existing processing pipelines that worked with previous versions. The version in which the behavior changed remains to be identified.
- 主要语言
- HTML
- 星标
- 12
- 派生
- 6
- 平均合并
- 36 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
InseeFrLab/rtauargus 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
InseeFrLab/rtauargus#63 ·
-
bug
难度 4/5 3-5 天 新手友好度 48/100
InseeFrLab/rtauargus#68 · 1 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
InseeFrLab/rtauargus#66 · 1 条评论 ·
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
InseeFrLab/rtauargus#58 ·
-
pouvoir ignorer field_columns dans format_template()可能重新可做 @clara-baudry 于 379 天前认领,目前没有进行中的 PR。 未关闭
InseeFrLab/rtauargus#34 · 已指派 1 人 ·
查看 InseeFrLab/rtauargus 的全部 Issue
相似的 Issue
-
auto:producer auto:security
难度 2/5 1-3 小时 新手友好度 66/100
fritzprix/libr-agent#2595 ·
维护者通常 1 天内回复
-
area: infrastructure bug priority: low
难度 2/5 1-3 小时 新手友好度 78/100
snapotter-hq/SnapOtter#4573 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 83/100
-
comp: ssr comp: zones type: feature version: current (v17+)
难度 2/5 1-3 小时 新手友好度 84/100
angular/angularfire#3836 ·
维护者通常 3 天内回复