Skip to content

Update wording on 1-level check #43

@tsostarics

Description

@tsostarics

Consider a dataframe with two factor columns x and y, where x has only one level and y has more than one level.

> data.frame(x = factor(c(1, 1)),
+            y = gl(2,1)) |> 
+   set_contrasts(x ~ sum_code)
Expect contr.treatment or contr.poly for unset factors: y
Error in enlist_contrasts(model_data, !!!formulas, verbose = verbose) : 
  No factors with more than 1 level found
In addition: Warning message:
Contrasts undefined for factors with only one level: x 

The error states "No factors with more than 1 level found", with the intent being "I didn't find a factor with more than 1 level in the factors you specified in your set_contrasts call". An alternative, more exhaustive, reading is "I looked at the rest of the data in the dataframe and didn't see any factors with more than 1 level". This is confusing, as it suggests that the function checked y and incorrectly determined that it, too, had 1 level.

The wording should be adjusted to be No factors with more than 1 level were provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions