【发布时间】:2020-06-29 12:40:41
【问题描述】:
我是一个 Python 人,被要求运行一些返回以下错误的 R 代码:
错误:
...不为空。我们检测到这些有问题的论点:
..1这些点仅用于允许将来扩展,应该为空。 你是否错误地指定了一个论点?运行
rlang::last_error()看看在哪里 发生错误。
我可以将代码简化为这个 MWE:
library(dplyr)
x <- data.frame(1)
x %>% ungroup(x)
我不知道第 3 行应该做什么,但它在我的系统 (dplyr 1.0.0) 上失败,同时使用 dplyr 0.8.5 或https://rdrr.io/snippets/,它打印在哪里
X1
1 1
我尝试了很多事情,但没有成功:
update.packages(ask = FALSE)
remove.packages("dplyr")
install.packages("dplyr")
这里发生了什么?我该如何(帮助)调查?
更新:options(error = recover) 给了我这个:
1: x %>% ungroup(x)
2: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
3: eval(quote(`_fseq`(`_lhs`)), env, env)
4: eval(quote(`_fseq`(`_lhs`)), env, env)
5: `_fseq`(`_lhs`)
6: freduce(value, `_function_list`)
7: withVisible(function_list[[k]](value))
8: function_list[[k]](value)
9: ungroup(., x)
10: ungroup.data.frame(., x)
11: ellipsis::check_dots_empty()
12: action_dots(action = action, message = "`...` is not empty.", dot_names = n
13: action(message, .subclass = c(.subclass, "rlib_error_dots"), ...)
14: signal_abort(cnd)
另一个更新:complete line of code,非最小化,如果重要的话,是
screenData <- mutate_if(screenData, is.character, as.factor) %>% ungroup(screenData)
也许这比我的 MWE 更有意义。
另一个:dput(screenData)返回
structure(list(wellID = "A001", rowID = "A0", colID = "01", value = 0,
fileName = "V3_Prob5_p1", batch = structure(NA_integer_, .Label = character(0), class = "factor"),
sampleID = NA, patientID = NA, name = NA_character_, concentration = NA_real_,
wellType = "sample"), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame"))
最后,我向代码的维护者提出了一个问题,请参阅https://github.com/lujunyan1118/DrugScreenExplorer/issues/1,
和dplyr,见https://github.com/tidyverse/dplyr/issues/5368
【问题讨论】:
-
我在未加载包 'dplyr' 时收到此错误。你确定已经安装然后用
library(dplyr)正确加载dplyr@ -
跟随 ljwharbers 评论,尝试:x % dplyr::ungroup(x) 告诉我们它是否有效
-
@ljwharbers 什么?不。当包没有加载时,你会得到一个不同的错误(“找不到函数‘ungroup’”)。
-
x %>% ungroup(x)运行ungroup(x,x)。 -
@LeonIpdjian 没有
library(dplyr),无法找到%>%。使用library(dplyr),和以前一样的错误。