Skip to content

Instantly share code, notes, and snippets.

Carl Frederick carlbfrederick

Block or report user

Report or block carlbfrederick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sampleLatoReport.Rmd
---
title: "Sample Lato .Rmd"
author: "Carl Frederick"
date: "11/12/2018"
mainfont: Lato
output:
pdf_document:
latex_engine: xelatex
---
@carlbfrederick
carlbfrederick / DescribeDataSharing.R
Created Jul 20, 2018
Using babynames package to illustrate complex data sharing
View DescribeDataSharing.R
library(babynames)
library(tidyverse)
set.seed(8746)
snames <- sample(babynames$name, 14)
unames <- snames[11:14]
snames <- snames[1:10]
Agency1 <- data_frame(Person = c(sample(snames, 5), unames[1]),
@carlbfrederick
carlbfrederick / dataMaid_cleanPlot.R
Created Jul 10, 2018
4th attempt at clean plots for data documentation
View dataMaid_cleanPlot.R
#'dataMaid_cleanPlot.R
#'
#'These functions makes the default graphics prettier/easier to read:
#'
#' 1. Minimal Theme
#' 2. Angled Axis Text
#'
#' @example
cleanPlotHelper <- function(data, vnam, sideways) {
@carlbfrederick
carlbfrederick / dataMaid_isIDvar.R
Last active Jan 11, 2019
dataMaid check function: deal with "key" variables that do not uniquely identify rows
View dataMaid_isIDvar.R
#'dataMaid_isIDvar.R
#'
#'This function identifies "Key" and similar variables and stops dataMaid::makeDataReport from creating
#'visualizations and/or other inappropriate summaries. Instead it outputs a table with minimal information
#'(see https://cran.rstudio.com/web/packages/dataMaid/vignettes/extending_dataMaid.html for inspiration).
#'
#' @example
#' makeDataReport(toyData, output = "html",
#' preChecks = c("isKey", "isSingular", "isSupported", "isIDvar"))
@carlbfrederick
carlbfrederick / packageFunctionMap.R
Last active Apr 2, 2019
Visualize internal package functions
View packageFunctionMap.R
library(tidyverse)
library(DiagrammeR)
#Get package functions ----
ls_fcns <- function(pkg) {
fcns <- unclass(lsf.str(envir = asNamespace(pkg), all = TRUE))
return(as.character(fcns))
}
@carlbfrederick
carlbfrederick / survProbs.coxme.R
Last active Sep 2, 2015
I wrote these functions to calculate survival probabilities at various levels of the random effect estimate from a coxme.object. The code is heavily adapted from survfit.coxph(). It should work, but all errors and inelegant hacks I have introduced are certainly my own doing. Comments/improvements welcome, enjoy!
View survProbs.coxme.R
#Internal Functions
MYagsurv <- function(y, x, wt, risk, survtype=3, vartype=3) {
nvar <- ncol(as.matrix(x))
status <- y[, ncol(y)]
dtime <- y[, ncol(y) - 1]
death <- (status == 1)
time <- sort(unique(dtime))
nevent <- as.vector(rowsum(wt * death, dtime))
ncens <- as.vector(rowsum(wt * (!death), dtime))
wrisk <- c(wt * risk) #Had to add c() to remove the dimnames so that the multiplication later would work
You can’t perform that action at this time.