Skip to content

add_row chokes with grouped .data #179

Description

@dhicks

MWE:

a = c(rep('z', 5), rep('y', 5))
tbl = tibble(a, b = 1:10)
a_prime = rep('x', 5)
add_row(tbl, a = a_prime)

This works fine.

add_row(group_by(tbl, a), a = a_prime)

This throws an error Error: is.data.frame(df) is not TRUE. It looks like, when the grouped dataframe is sent to rbind, rbind returns a matrix of dataframes. remove_rownames then (quite reasonably) doesn't know what to do with this mess a few lines later.

Activity

jennybc commented on Oct 11, 2016

@jennybc
Member

Aside from the fact that add_row() is not (yet) prepared to operate on an object of class grouped_df, it's not clear what the correct result would be.

What should the status of the new row(s) be w/r/t the groups?

krlmlr commented on Oct 12, 2016

@krlmlr
Member

I agree that the error message could be clearer, but I'd rather not support adding rows to a grouped df.

dhicks commented on Oct 12, 2016

@dhicks
Author

In my actual use case, it was simple enough to ungroup(), add_row(), and then re-group_by(). So a more perspicuous error message would have worked fine for me.

added this to the 1.3.0 milestone on Jan 4, 2017
added a commit that references this issue on Jan 9, 2017
added a commit that references this issue on Apr 1, 2017

github-actions commented on Dec 14, 2020

@github-actions
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

locked and limited conversation to collaborators on Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorcategory:interface

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions