Reputation: 5771
I'm a Python guy who is asked to run some R code that returns the following error:
Error:
...
is not empty.We detected these problematic arguments:
..1
These dots only exist to allow future extensions and should be empty. Did you misspecify an argument? Run
rlang::last_error()
to see where the error occurred.
I could reduce the code to this MWE:
library(dplyr)
x <- data.frame(1)
x %>% ungroup(x)
I have no idea what line 3 is supposed to do, but it fails on my system (dplyr 1.0.0), while working using dplyr 0.8.5 or on https://rdrr.io/snippets/, where it prints
X1
1 1
I have tried a number of things, with no success:
update.packages(ask = FALSE)
remove.packages("dplyr")
install.packages("dplyr")
What is going on here? How can I (help) investigate?
Update: options(error = recover)
gives me this:
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)
Another update: the complete line of code, non-minimized, if that matters, is
screenData <- mutate_if(screenData, is.character, as.factor) %>% ungroup(screenData)
Maybe that makes more sense than my MWE.
Another one: dput(screenData)
returns
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
Upvotes: 1
Views: 7428
Reputation: 527
It seems an issue with tibble
package. See here.
Updating tibble
solved the issue for me.
Upvotes: 0
Reputation: 12451
The pipe %>%
is syntactic sugar. It means "take the object on the left hand side of the pipe and use it as the first argument to the function on the right-hand side of the pipe".
So you can say ungroup(x)
or x %>% ungroup()
, both of which work, but x %>% ungroup(x)
is trying to both ungroup a data.frame called x
and remove a variable called x
from the grouping of the data.frame called x
. But the data.frame x
doesn't contain a variable called x
. Hence the problem.
The code you've been given is inherently wrong (or at the very least confusingly written).
Update
Following the post of your dput
.
screenData %>% ungroup(screenData)
is equivalent to ungroup(screenData, screenData)
where the first screenData
is the data.frame to ungroup and the second is the name of the variable in the data.frame to remove from the grouping. but the data.frame screenData
does not contain a column called screenData
. That's why you get an error.
The code you have been given is unequivocally incorrect.
The fact that it ran without error in a previous version of dplyr
is purely accidental.
Upvotes: 4
Reputation: 545508
The ungroup
function takes no extra arguments. The code you’ve been provided with is wrong. Remove x
from the ungroup
call.
Upvotes: 1