Display name
Display name

Reputation: 4481

Does tidyr complete() use the dplyr group_by() function?

Does tidyr complete() use the dplyr group_by() function? I'm asking because I want to know if I need to ungroup() after using the complete() function.

I couldn't find an answer in the tidyr reference page.

Upvotes: 0

Views: 93

Answers (1)

Fnguyen
Fnguyen

Reputation: 1177

As the reference page you link states:

Turns implicit missing values into explicit missing values. This is a wrapper around expand(), dplyr::left_join() and replace_na() that's useful for completing missing combinations of data.

So the three operations that are used do not include group_by() and indeed from a logical standpoint there is no need for a grouping-operation in complete().

Finally as @Matt states:

You can also use is_grouped_df()

This will simply confirm that the dataframe is not grouped.

Upvotes: 1

Related Questions