Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dplyr::row_number get error inside mutate #3008

Closed
italocegatta opened this issue Aug 2, 2017 · 1 comment
Closed

dplyr::row_number get error inside mutate #3008

italocegatta opened this issue Aug 2, 2017 · 1 comment

Comments

@italocegatta
Copy link

If I use row_number() works well, but if I call dplyr::row_number() returns an error

library(dplyr)

packageVersion("dplyr")
#> [1] '0.7.2'

iris <- head(iris)

mutate(iris, id = row_number())
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species id
#> 1          5.1         3.5          1.4         0.2  setosa  1
#> 2          4.9         3.0          1.4         0.2  setosa  2
#> 3          4.7         3.2          1.3         0.2  setosa  3
#> 4          4.6         3.1          1.5         0.2  setosa  4
#> 5          5.0         3.6          1.4         0.2  setosa  5
#> 6          5.4         3.9          1.7         0.4  setosa  6

mutate(iris, id = dplyr::row_number())
#> Error in mutate_impl(.data, dots) : 
#>   Evaluation error: argument "x" is missing, with no default.
@foo-bar-baz-qux
Copy link
Contributor

I don't think row_number() without any ordering parameter has a consistent interpretation in SQL/relational databases in general, and since the dplyr::row_number() is based on SQL2003, it would make sense that it returns an error.

I assume the native row_number() just returns the "original" ordering, like mutate(iris, id = 1:NROW(iris)), but if anything, it seems like this native version should in fact return an error if dplyr is based on a SQL style interface.

@hadley hadley closed this as completed Aug 23, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants