dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
502 stars 77 forks source link

Do not check grouped_df by callstack in ctable #175

Open Thibaultfq opened 1 year ago

Thibaultfq commented 1 year ago

The source code in ctable.R uses the callstack to check for group_by.

# Check for group_by() if (any(grepl("group_by(", deparse(sys.calls()[[1]]), fixed = TRUE))) { stop("ctable() doesn't support group_by(); use stby() instead") } ctable.R

This stops my code for a dataframe that i for several reasons first grouped by later ungrouped. It perfectly runs though, because i provide a non-grouped df. The current workaround is to assign to grouped+ungrouped df to a variable and use this variable in the R console to call the ctable function. Isn't there a better way to check the use of a grouped df? (eg. is.grouped_df)