tidymodels / infer
Showing 2 of 3 files from the diff.

@@ -306,6 +306,15 @@
Loading
306 306
      res[["statistic"]]
307 307
    }
308 308
309 +
    # Warn about possible unused factor levels
310 +
    if (has_unused_levels(x[[expl_var]])) {
311 +
      warning_glue("Explanatory variable has unused factor levels.")
312 +
    }
313 +
    if (has_unused_levels(x[[resp_var]])) {
314 +
      warning_glue("Response variable has unused factor levels.")
315 +
    }
316 +
317 +
    # Compute result
309 318
    result <- x %>%
310 319
      dplyr::nest_by(.key = "data") %>%
311 320
      dplyr::summarise(stat = chisq_indep(data), .groups = "drop")

@@ -308,6 +308,17 @@
Loading
308 308
  }
309 309
}
310 310
311 +
has_unused_levels <- function(x) {
312 +
  if (is.factor(x)) {
313 +
    present_levels <- unique(as.character(x))
314 +
    unused_levels <- setdiff(levels(x), present_levels)
315 +
316 +
    length(unused_levels) > 0
317 +
  } else {
318 +
    FALSE
319 +
  }
320 +
}
321 +
311 322
# Helpers for hypothesize() -----------------------------------------------
312 323
313 324
match_null_hypothesis <- function(null) {
@@ -519,4 +530,4 @@
Loading
519 530
  }
520 531
  
521 532
  TRUE
522 -
}
Files Coverage
R 99.84%
Project Totals (15 files) 99.84%
1
comment:
2
  layout: "reach, diff, flags, files"
3
  behavior: default
4
  require_changes: false  # if true: only post the comment if coverage changes
5
  require_base: no        # [yes :: must have a base report to post]
6
  require_head: yes       # [yes :: must have a head report to post]
7
  branches: null
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading