![](/img/trans.png)
[英]Why do I get 'The directory '.' is not empty' using R Blogdown
[英]Why do I get “Error: `…` is not empty” in R?
我是一個 Python 人,他被要求運行一些返回以下錯誤的 R 代碼:
錯誤:
...
不為空。我們檢測到這些有問題的 arguments:
..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)
另一個更新: 完整的代碼行,非最小化,如果重要的話,是
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"))
Finally, I opened an issue with the maintainer of the code, see https://github.com/lujunyan1118/DrugScreenExplorer/issues/1 , and with dplyr
, see https://github.com/tidyverse/dplyr/issues/5368
pipe %>%
是語法糖。 這意味着“將 pipe 左側的 object 用作管道右側 function 的第一個參數”。
因此,您可以說ungroup(x)
或x %>% ungroup()
,兩者都有效,但是x %>% ungroup(x)
x
嘗試將名為x
的 data.frame 取消組合並從data.frame 的分組稱為x
。 但 data.frame x
不包含名為x
的變量。 因此問題。
你得到的代碼本質上是錯誤的(或者至少寫得令人困惑)。
在您的dput
發布之后更新。
screenData %>% ungroup(screenData)
等價於ungroup(screenData, screenData)
其中第一個screenData
是要取消分組的 data.frame,第二個是要從分組中刪除的 data.frame 中的變量名稱。 但 data.frame screenData
不包含名為screenData
的列。 這就是你得到錯誤的原因。
你得到的代碼是明確不正確的。
它在之前版本的dplyr
中運行沒有錯誤的事實純屬偶然。
ungroup
function 不需要額外的 arguments。 您提供的代碼是錯誤的。 從ungroup
呼叫中刪除x
。
tibble
package 似乎有問題。 見這里。
更新tibble
為我解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.