在R中取消按行分组的DataFrame分组的技术问询
It looks like your tibble is in row-wise grouping mode (usually from using rowwise() at some point) rather than being grouped by a specific column. That's why standard grouping-related functions might not behave as expected. Here are a few straightforward ways to revert it to a regular ungrouped tibble:
Use
ungroup()directly: Even for row-wise grouped tibbles,ungroup()should strip away the row-wise grouping:df <- df %>% ungroup()Disable row-wise mode explicitly: If
ungroup()doesn't do the trick, you can turn off row-wise grouping directly with:df <- df %>% rowwise(FALSE)Convert to a regular tibble/data frame: Sometimes a simple conversion will reset the grouping state entirely:
# To tibble df <- as_tibble(df) # Or to data frame df <- as.data.frame(df)
You can verify that the grouping is gone by running group_vars(df) — it should return an empty vector (character(0)) once the tibble is ungrouped.
内容的提问来源于stack exchange,提问作者SumitArya

