Last active
March 5, 2021 01:57
-
-
Save pgstevenson/9cba21613db22434e58240d9ef0c60d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <- function(d, est, se, p, expo = FALSE, dp = "%0.2f") { | |
mutate(d, | |
ci.lo = {{est}} - {{se}} * qnorm((1 + 0.95)/2), | |
ci.hi = {{est}} + {{se}} * qnorm((1 + 0.95)/2), | |
p.stars = case_when({{p}} < 0.001 ~ "***", | |
{{p}} < 0.01 ~ "**", | |
{{p}} < 0.05 ~ "*", | |
TRUE ~ ""), | |
across(c({{est}}, "ci.lo", "ci.hi"), ~case_when(expo ~ exp(.), TRUE ~ .)), | |
across(c({{est}}, "ci.lo", "ci.hi"), ~sprintf(dp, .)), | |
txt = paste0({{est}}, " (95% CI: ", ci.lo, " to ", ci.hi, ")", p.stars)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment