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

rowwise() is not generic #2934

Closed
echasnovski opened this issue Jul 2, 2017 · 1 comment
Closed

rowwise() is not generic #2934

echasnovski opened this issue Jul 2, 2017 · 1 comment

Comments

@echasnovski
Copy link
Contributor

I need to define a class that will work tightly with dplyr. As suggested in #1429 "...you need to define a method for your class for each dplyr method that correctly restores all the classes and attributes...". For most verbs it can be done because they are implemented as generic functions but not rowwise() (namely in dplyr 0.7.1). I understand that it only works with data frames but in current implementation one can't define a method for classes inheriting data.frame.

Is it intentional or just missing functionality? Maybe something like this might be better:

rowwise <- function(data) {
  UseMethod("rowwise")
}

rowwise.default <- function(data) {
  stop("Input should be a data.frame.")
}

rowwise.data.frame <- function(data) {
  assert_all_white_list(data)
  structure(data, class = c("rowwise_df", "tbl_df", "tbl", "data.frame"))
}
@hadley
Copy link
Member

hadley commented Jul 13, 2017

rowwise() is a constructor, not a coercer, should shouldn't be a generic. Generally, we're moving away from the rowwise class.

@hadley hadley closed this as completed Jul 13, 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

2 participants