Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unclear error message #762

Open
BFalquet opened this issue Jul 1, 2024 · 0 comments
Open

unclear error message #762

BFalquet opened this issue Jul 1, 2024 · 0 comments
Labels
bug Something isn't working chevron

Comments

@BFalquet
Copy link
Contributor

BFalquet commented Jul 1, 2024

It is not really an error but the message is missleading, the issue is that the number of levels in the variable should be >= 1 be It is actually ok if the variable is of length 0. (and there is no bug if it is a character.)

Should we be more tolerant, should we improve the error message or force the users to use factors ?

library(chevron)
#> Registered S3 method overwritten by 'tern':
#>   method   from 
#>   tidy.glm broom
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
proc_data <- syn_data
proc_data$addv <- proc_data$addv[NULL, ]

preprocess(pdt01) <-
  function(adam_db, ...) {
    adam_db$addv <- adam_db$addv %>%
      
      mutate(across(all_of(c(
        "DVSCAT",
        "DVTERM"
      )), ~ reformat(.x, nocoding))) %>%
      mutate(
        DVSCAT = with_label(
          .data$DVSCAT,
          "Category"
        ),
        DVTERM = with_label(
          .data$DVTERM,
          "Category"
        )
      ) %>% 
      mutate(DVTERM = stringr::str_wrap(DVTERM, width = 50))
    adam_db %>% dunlin::log_filter(.data$DVCAT == "MAJOR", "addv")
  }

run(pdt01, proc_data)
#> Error in tryCatch(withCallingHandlers({: 1 assertions failed:
#>  * Variable 'adam_db$addv$DVTERM': Must have length >= 1, but has
#>  * length 0.
Created on 2024-07-01 with [reprex v2.1.0](https://reprex.tidyverse.org/)
@BFalquet BFalquet added bug Something isn't working chevron labels Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chevron
Projects
None yet
Development

No branches or pull requests

1 participant