diff --git a/DESCRIPTION b/DESCRIPTION index 981cb17..dacc8e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,4 +26,3 @@ Suggests: covr, testthat, vdiffr -RoxygenNote: 7.1.2 diff --git a/R/forest_model.R b/R/forest_model.R index 9ccc6fb..a171eaa 100644 --- a/R/forest_model.R +++ b/R/forest_model.R @@ -241,7 +241,7 @@ forest_model <- function(model, ) if (inherits(model, "coxph")) { event_detail_tab <- lapply( - setNames(seq_len(ncol(model$y)), colnames(model$y)), + stats::setNames(seq_len(ncol(model$y)), colnames(model$y)), function(y_col) { apply( cols, @@ -277,10 +277,17 @@ forest_model <- function(model, seq_along(interaction_terms), function(i) { if (term_row$interaction_terms_are_factors[[1]][i]) { - ilv <- tibble::tibble( - level = model$xlevels[[remove_backticks(interaction_terms[i])]], - label = paste0(interaction_terms[i], level) - ) + if (term_row$interaction_terms_are_logical[[1]][i]) { + ilv <- tibble::tibble( + level = c("FALSE", "TRUE"), + label = paste0(interaction_terms[i], level) + ) + } else { + ilv <- tibble::tibble( + level = model$xlevels[[remove_backticks(interaction_terms[i])]], + label = paste0(interaction_terms[i], level) + ) + } } else { ilv <- tibble::tibble(level = NA, label = interaction_terms[i]) } @@ -459,6 +466,7 @@ make_forest_terms_basic <- function(model) { is_interaction = colSums(mdl_factors) > 1, interaction_terms = lapply(term_label, function(tl) names(which(attr(mdl_terms, "factors")[, tl] == 1))), interaction_vars = lapply(interaction_terms, remove_backticks), - interaction_terms_are_factors = lapply(interaction_vars, function(iv) mdl_data_classes_factors[iv]) + interaction_terms_are_factors = lapply(interaction_vars, function(iv) mdl_data_classes_factors[iv]), + interaction_terms_are_logical = lapply(interaction_vars, function(iv) mdl_terms_are_logical[iv]) ) } diff --git a/R/model_frame_coxph_simple.R b/R/model_frame_coxph_simple.R index 566cc0d..edd5cbf 100644 --- a/R/model_frame_coxph_simple.R +++ b/R/model_frame_coxph_simple.R @@ -1,5 +1,5 @@ model_frame_coxph_simple <- function(model) { - cph_terms <- terms(model) + cph_terms <- stats::terms(model) fcall <- model$call indx <- match(c("formula", "data", "weights", "subset", "na.action", "cluster", "id", "istate"), names(fcall), diff --git a/tests/testthat/_snaps/forest_model/sample-forest-model-plot-for-lung.svg b/tests/testthat/_snaps/forest_model/sample-forest-model-plot-for-lung.svg index 118c812..8491eb8 100644 --- a/tests/testthat/_snaps/forest_model/sample-forest-model-plot-for-lung.svg +++ b/tests/testthat/_snaps/forest_model/sample-forest-model-plot-for-lung.svg @@ -27,10 +27,10 @@ - - - - + + + + diff --git a/tests/testthat/_snaps/forest_rma/sample-forest-rma-plot-for-dat-bcg.svg b/tests/testthat/_snaps/forest_rma/sample-forest-rma-plot-for-dat-bcg.svg index 763f899..88b497b 100644 --- a/tests/testthat/_snaps/forest_rma/sample-forest-rma-plot-for-dat-bcg.svg +++ b/tests/testthat/_snaps/forest_rma/sample-forest-rma-plot-for-dat-bcg.svg @@ -27,14 +27,14 @@ - - - - - - - - + + + + + + + + @@ -89,7 +89,7 @@ - + Aronson 1948 Ferguson & Simes 1949 Rosenthal et al 1960