Skip to content

Instantly share code, notes, and snippets.

############################################################
# Hosmer-Lemeshow test
############################################################
hosmerlem = function(observed, predicted, g = 10) {
cutyhat = cut(predicted,
breaks = quantile(predicted,
probs=seq(0, 1, 1/g)),
include.lowest=TRUE)
# Construct a couple sample normal distributions
# and set x limits for plotting
x <- seq(from = 110, to = 174, by = 0.5)
y1 <- dnorm(x, mean = 145, sd = 9)
y2 <- dnorm(x, mean = 138, sd = 8)
# Plot outline of first distribution
# with titles and labels
plot(x, y1, type="l", lwd=2, col="red",
main="Systolic Blood Pressure Before and After Treatment",
########################################
########################################
#
# Building barplots in R with
# error bars
#
########################################
########################################
########################################
########################################
########################################
#
# Conducting t-tests in R
#
########################################
########################################
########################################
# One-sample t-tests
########################################
########################################
#
# Repeated Measures ANOVAs in R
#
########################################
########################################
########################################
# Construct a sample dataset
server <- function(input, output, session) {
###
output$sliders <- renderUI({
xv <- input$xaxisGrp
# First, create a list of sliders each with a different name
sliders <- lapply(1:length(xv), function(i) {
inputName <- xv[i]
sliderInput(
inputId = inputName,
@wetherc
wetherc / README.md
Last active October 19, 2016 15:50
Code Review Cheat Sheet

Save Changes in Git

$ git add --all
$ git commit -a -m "My commit message"

Create A Code Review

$ arc diff --amend-all
@wetherc
wetherc / app.R
Last active August 10, 2017 15:10
Dynamic Tab Panels
library(shiny)
################################################################################
#
# GLOBALS
#
################################################################################
# On application start, we'll randomly choose whether
# the viewer can see our super-secret Old Faithful tab
@wetherc
wetherc / groupByCoverageWindow.R
Last active September 27, 2017 17:03
Group policies by periods of continuous coverage
library(data.table)
################################################################################
#
# Generate some dummy data
#
################################################################################
data <- data.frame(
policyId = "A",
@wetherc
wetherc / cd
Created October 19, 2017 00:27
Pushd / Popd example
# Do some work in my home directory
chriss-MacBook-Pro:~ chris$ pwd
/Users/chris
chriss-MacBook-Pro:~ chris$ vim myAwesomeCode.py
chriss-MacBook-Pro:~ chris$ python myAwesomeCode.py
# Switch directories real quick
chriss-MacBook-Pro:~ chris$ cd /etc
chriss-MacBook-Pro:etc chris$ vim hosts