Skip to content

replacement has lenght zero #42

@verajosemanuel

Description

@verajosemanuel

Error: Problem with `mutate()` column `predicted`.
i `predicted = make_two_class_pred(...)`.
x replacement has length zero
Run `rlang::last_error()` to see where the error occurred.
In addition: Warning message:
Problem with `mutate()` column `predicted`.
i `predicted = make_two_class_pred(...)`.
i 'x' is NULL so the result will be NULL 

Reproducible example

dm <- structure(list(pred_convert = c(0.1283158659935, 0.147706210613251, 
                                0.124467730522156, 0.137504696846008,
                                0.115710318088531, 0.0456064343452454),
            class = c("non_convert", "convert",
             "non_convert", "non_convert", 
             "non_convert", "non_convert"),
package = structure(c(2L, 3L, 2L,
                      2L, 2L, 2L),
                    .Label = c("111", "112", "121",
                               "131", "211", "221"),
                    class = "factor"),
acc = c(0L, 0L, 0L, 0L, 0L, 0L)),
row.names = c(1L, 2L, 3L, 4L, 5L, 6L),
class = "data.frame")


lvls <- levels(as.factor(dm$class))

dm %>% 
  dplyr::mutate(
    predicted = make_two_class_pred(
      estimate = pred_convert,
      levels = levels(lvls),
      threshold = .12
    )
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions