I hereby claim:
- I am icj on github.
- I am icj (https://keybase.io/icj) on keybase.
- I have a public key ASD0JNOC-vnkIM4CiceSI6psuD6kcxOeetVfFOPVTKuknwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
scrub_tableby <- function(x) { | |
x <- summary(x) | |
df <- x$object | |
idx <- colnames(df) %nin% c("variable", "term", "label", "variable.type", | |
"test", "p.value") | |
format_all <- function(x, ...) vapply(x, format, NA_character_, ...) | |
df[idx] <- lapply(df[idx], format_all, | |
digits = x$control$digits, | |
format = "f", # the format="f" is not used for tbstat objects |
.icj_survcomb <- function(x, rel_ht = c(4, 1), ...) { | |
# Function to stack the survival curve and the risk table | |
# Args | |
# x: the output of .icj_ggsurv() | |
# rel_ht: relative size of plot and table (see cowplot::plot_grid) | |
# ...: other arguments to cowplot::plot_grid() | |
# | |
# Value | |
# a ggplot object containing both the curve and the risk table | |
library(ggplot2) |
summ_cont1 <- function(df, group, value, | |
header = NULL, digits = 1, na.rm = TRUE, | |
center = median, lower = min, upper = max, | |
total_col = "Total", overall_n = TRUE, | |
missing_group = "Missing", | |
missing_row = TRUE, missing_digits = 0, | |
lower_upper_divider = "-") { | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(dplyr) | |
library(gridExtra) | |
library(jsonlite) | |
json_colors <- fromJSON("https://raw.githubusercontent.com/teamcolors/teamcolors.github.io/master/assets/data/team-colors.json") | |
team_colors <- bind_rows( | |
lapply(names(json_colors), function(league) { | |
names(json_colors[[league]]$color$hex) <- json_colors[[league]]$team |
over_under <- function(df, x, y, cut_line, over_col = "red", under_col = "dodgerblue") { | |
# Creates an over-under plot | |
# | |
# Args | |
# df: data frame containing x and y axes variables | |
# x: name (character) or index of column containing x-axis variable | |
# y: name (character) or index of column containing y-axis variable | |
# cut_line: value that divides y into over and under regions | |
# over_col: color of over region | |
# under_col: color of under region |