brad-cannell / codebookr

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

Add informative error when user passes a column name with a typo to cb_add_col_attributes #42

Open mbcann01 opened 1 year ago

mbcann01 commented 1 year ago

Overview

I was working on the L2C data.

l2c_sample |> 

  cb_add_col_attributes(
    ml_gener, 
    description = "Master log gender",
    source = "Mater Log",
    col_type = "Categorical"
  )

And got the following error

Error in attr(df[[.x]], arg_names[i]) <- args[[i]] : 
  attempt to set an attribute on NULL

The problem was that I typed ml_gener as the column name instead of ml_gender. We should try to catch this and give an informative error.