Skip to content

Instantly share code, notes, and snippets.

View nutterb's full-sized avatar

Benjamin nutterb

  • Battelle Memorial Institute
  • Kentucky
View GitHub Profile
library(dplyr)
library(tidyr)
choose_partner <- function(People){
Males <- filter(People, gender == "M")
Females <- filter(People, gender == "F")
if (nrow(Males) <= nrow(Females)){
Males$partner_id <- sample(Females$id, nrow(Males))
People <- full_join(Males, Females,
@nutterb
nutterb / ggSurvGraph_Examples.R
Created March 10, 2015 13:19
Examples using ggSurvGraph
#* You'll have to source in the function code from the gist
#* https://gist.github.com/nutterb/004ade595ec6932a0c29
library(ggplot2)
install.packages("KMsurv")
data(kidney, package="KMsurv")
fit <- survfit(Surv(time, delta) ~ type, data=kidney)
ggSurvGraph(fit)
ggSurvGraph(fit, conf.bar=FALSE)
@nutterb
nutterb / ggSurvGraph.R
Last active August 29, 2015 14:16
Customizable Survival Curves in ggplot2
#* More examples at https://gist.github.com/nutterb/fb19644cc18c4e64d12a
#' @name ggSurvGraph
#' @export ggSurvGraph
#' @import ggplot2
#' @importFrom grid unit
#' @importFrom gridExtra grid.arrange
#' @importFrom plyr arrange
#' @importFrom plyr ddply
#' @importFrom reshape2 melt
#' @importFrom zoo na.locf
@nutterb
nutterb / missingSummary.R
Last active March 7, 2023 21:47
Generate a Report of Fields with Missing Values in a REDCap Database Using the redcapAPI package
#### Intended for use with the `redcapAPI` package
#' @name missingSummary
#' @aliases missingSummary.redcapApiConnection
#' @aliases missingSummary.redcapDbConneciton
#' @aliases missingSummary_offline
#' @export missingSummary
#' @export missingSummary.redcapApiConnection
#' @export missingSummary.redcapDbConnection
#' @export missingSummary_offline
#'