Skip to content

Commit

Permalink
coerce estimator_label to character
Browse files Browse the repository at this point in the history
  • Loading branch information
graemeblair committed Feb 3, 2019
1 parent 9f29306 commit 9929611
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/diagnosis_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ reshape_diagnosis <- function(diagnosis, digits = 2, select = NULL) {
for(i in c(parameter_names, "design_label")) {
levels(return_df[[i]]) <- c(levels(return_df[[i]]), "")
}
return_df$estimator_label <- as.character(return_df$estimator_label)
return_df[return_df$statistic == "SE", c(sort_by_list, parameter_names, "n_sims")] <- ""
return_df$statistic <- NULL

Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-reshape-diagnosis.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,26 @@ test_that("select", {
reshape <- reshape_diagnosis(dx, select = "Bias")
expect_equal(colnames(reshape), c("Design Label", "Estimand Label", "Estimator Label", "Term", "N Sims", "Bias"))
})


test_that("designs with factors in diagnosands_df do not produce warnings", {

my_estimator <- function(data) {
data.frame(estimate = c("answer1", "answer2"))
}

design <- design <- my_population +
declare_estimator(handler = tidy_estimator(my_estimator), label = "my_label")

diagnose_design(design, sims = 2, diagnosands = declare_diagnosands(first = first(estimate), keep_defaults = FALSE))

my_estimator <- function(data) {
data.frame(estimate = c("answer1", "answer2"), estimator_label = "my_label")
}

design <- design <- my_population +
declare_estimator(handler = my_estimator)

expect_silent(reshape_diagnosis(diagnose_design(design, sims = 2, diagnosands = declare_diagnosands(first = first(estimate), keep_defaults = FALSE))))

})

0 comments on commit 9929611

Please sign in to comment.