brad-cannell / codebookr

Create Codebooks From Data Frames
https://brad-cannell.github.io/codebookr/
Other
25 stars 6 forks source link

Add informative errors when user tries to do things like make sex numeric #7

Open mbcann01 opened 2 years ago

mbcann01 commented 2 years ago

For example

df <- data.frame(x = letters, y = 1:26)
df <- cb_add_col_attributes(df, x, col_type = "numeric")
codebook(df)

Returns the error

Error in `dplyr::mutate()`:
! Problem while computing `..1 = dplyr::across(dplyr::everything(), round, digits = digits)`.
Caused by error in `across()`:
! Problem while computing column `Min`.
Caused by error in `fn()`:
! non-numeric argument to mathematical function

We should figure out a way to intercept it and give something more informative.