|
142 | 142 | #' \code{show.df = TRUE} to show the approximated degrees of freedom |
143 | 143 | #' for each coefficient. |
144 | 144 | #' @param p.style Character, indicating if p-values should be printed as |
145 | | -#' numeric value (\code{"numeric"}), as asterisks (\code{"asterisk"}) |
146 | | -#' or both (\code{"both"}). May be abbreviated. |
| 145 | +#' numeric value (\code{"numeric"}), as 'stars' (asterisks) only (\code{"stars"}), |
| 146 | +#' or scientific (\code{"scientific"}). Scientific and numeric style can be |
| 147 | +#' combined with "stars", e.g. \code{"numeric_stars"} |
147 | 148 | #' @param CSS A \code{\link{list}} with user-defined style-sheet-definitions, |
148 | 149 | #' according to the \href{http://www.w3.org/Style/CSS/}{official CSS syntax}. |
149 | 150 | #' See 'Details' or \href{https://strengejacke.github.io/sjPlot/articles/table_css.html}{this package-vignette}. |
@@ -308,7 +309,7 @@ tab_model <- function( |
308 | 309 | digits.p = 3, |
309 | 310 | emph.p = TRUE, |
310 | 311 | p.val = c("wald", "kenward", "kr", "satterthwaite", "ml1", "betwithin"), |
311 | | - p.style = c("numeric", "asterisk", "both"), |
| 312 | + p.style = c("numeric", "stars", "numeric_stars", "scientific", "scientific_stars"), |
312 | 313 | p.threshold = c(0.05, 0.01, 0.001), |
313 | 314 | p.adjust = NULL, |
314 | 315 |
|
@@ -337,7 +338,7 @@ tab_model <- function( |
337 | 338 | case <- NULL |
338 | 339 | } |
339 | 340 |
|
340 | | - if (p.style == "asterisk") show.p <- FALSE |
| 341 | + if (p.style == "stars") show.p <- FALSE |
341 | 342 |
|
342 | 343 | # default robust? |
343 | 344 | if (isTRUE(robust)) { |
@@ -468,10 +469,15 @@ tab_model <- function( |
468 | 469 | dplyr::select(-.data$conf.low, -.data$conf.high) %>% |
469 | 470 | dplyr::mutate( |
470 | 471 | p.stars = get_p_stars(.data$p.value, p.threshold), |
471 | | - p.sig = .data$p.value < .05, |
472 | | - p.value = sprintf("%.*f", digits.p, .data$p.value) |
| 472 | + p.sig = .data$p.value < .05 |
473 | 473 | ) |
474 | 474 |
|
| 475 | + if (grepl("scientific", p.style)) { |
| 476 | + dat$p.value <- formatC(dat$p.value, format = "e", digits = digits.p) |
| 477 | + } else { |
| 478 | + dat$p.value <- sprintf("%.*f", digits.p, dat$p.value) |
| 479 | + } |
| 480 | + |
475 | 481 |
|
476 | 482 | # emphasize p-values ---- |
477 | 483 |
|
@@ -519,6 +525,7 @@ tab_model <- function( |
519 | 525 | facets = FALSE, |
520 | 526 | show.zeroinf = show.zeroinf, |
521 | 527 | p.val = p.val, |
| 528 | + p_adjust = p.adjust, |
522 | 529 | standardize = std_method, |
523 | 530 | bootstrap = bootstrap, |
524 | 531 | iterations = iterations, |
@@ -546,7 +553,7 @@ tab_model <- function( |
546 | 553 |
|
547 | 554 | # add asterisks to estimates ---- |
548 | 555 |
|
549 | | - if (p.style %in% c("asterisk", "both")) { |
| 556 | + if (grepl("stars", p.style)) { |
550 | 557 | if (obj_has_name(dat, "estimate")) |
551 | 558 | dat$estimate <- sprintf("%.*f <sup>%s</sup>", digits, dat$estimate, dat$p.stars) |
552 | 559 | if (!show.est && obj_has_name(dat, "std.estimate")) |
@@ -1173,7 +1180,7 @@ tab_model <- function( |
1173 | 1180 | }) |
1174 | 1181 |
|
1175 | 1182 |
|
1176 | | - if (p.style %in% c("asterisk", "both")) |
| 1183 | + if (grepl("stars", p.style)) |
1177 | 1184 | footnote <- sprintf( |
1178 | 1185 | "* p<%s ** p<%s *** p<%s", |
1179 | 1186 | format(p.threshold[1]), |
|
0 commit comments