Skip to content

data.frame cast fallback #981

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

Closed
hadley opened this issue Mar 31, 2020 · 2 comments · Fixed by #1017
Closed

data.frame cast fallback #981

hadley opened this issue Mar 31, 2020 · 2 comments · Fixed by #1017
Assignees
Labels

Comments

@hadley
Copy link
Member

hadley commented Mar 31, 2020

I think we may need a some data.frame fallbacks so that we get something like this:

vec_rbind(tibble(x = 1), data.table(x = 1))
# Warning: combining <tibble> and <data.table>; falling back to <data.frame>

(This is not a general regret that we're moving away from inheritance; it's a specific pragmatic fallback + warning for people working with multiple data frame subclasses)

@lionel-
Copy link
Member

lionel- commented Apr 1, 2020

I like the idea, the warning will encourage people to normalise their inputs (we should link to a FAQ), and so their code won't be affected when the class authors end up implementing methods.

Implementation will probably require a sentinel data frame class to avoid repeat warnings.

@lionel-
Copy link
Member

lionel- commented Apr 1, 2020

Somehow it makes more sense for data frames than for other types. For example it wouldn't make sense to coerce factors to integers with a warning.

Maybe the general rule is that if a class explicitly inherits from one of the base classes (including data.frame), then a fallback + warning is in order? (Not that we should rush implementing a general fallback.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants