Skip to content

Instantly share code, notes, and snippets.

library(survival)
##----------
## example 1
set.seed(123)
group <- factor(rep(LETTERS[1:2], each=100))
Xbeta <- c(-1, 1)[unclass(group)] + rnorm(200, 0, 2)
weibA <- 1.5
weibB <- 100
U <- runif(200, 0, 1)
## DJV 1 target, see http://imgur.com/LHiZFeG
## unit x y -> cm
## points on outer polygon (ring 1)
djv1 <- read.table(file=textConnection("x y
25.4 67.9
21.2 59.3
27.5 49.4
36.7 46.2
50.4 46.2
57.2 47.3
@dwoll
dwoll / gist:a94b015acaf31ccff37b
Created January 22, 2016 11:16
check dummy.coef_mult
# check modified dummy.coef.lm(), print.dummy_coef()
# example from summary.manova
tear <- c(6.5, 6.2, 5.8, 6.5, 6.5, 6.9, 7.2, 6.9, 6.1, 6.3,
6.7, 6.6, 7.2, 7.1, 6.8, 7.1, 7.0, 7.2, 7.5, 7.6)
gloss <- c(9.5, 9.9, 9.6, 9.6, 9.2, 9.1, 10.0, 9.9, 9.5, 9.4,
9.1, 9.3, 8.3, 8.4, 8.5, 9.2, 8.8, 9.7, 10.1, 9.2)
opacity <- c(4.4, 6.4, 3.0, 4.1, 0.8, 5.7, 2.0, 3.9, 1.9, 5.7,
2.8, 4.1, 3.8, 1.6, 3.4, 8.4, 5.2, 6.9, 2.7, 1.9)
Y <- cbind(tear, gloss, opacity)
rate <- factor(gl(2, 10), labels = c("Low", "High"))
@dwoll
dwoll / dummy.coef_mult.R
Created January 22, 2016 11:14
dummy.coef() and print.dummy_coef() modified to deal with multivariate lm fits
# modified against R-Devel build 2016-01-22 r69971
# File src/library/stats/R/dummy.coef.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1998 B. D. Ripley
# Copyright (C) 1998-2015 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
knit_hooks$set(output=function(x, options) paste("\\[code\\]\n", x, "\\[/code\\]\n", sep=""))
knit_hooks$set(source=function(x, options) paste("\\[code lang='r'\\]\n", x, "\\[/code\\]\n", sep=""))
@dwoll
dwoll / gist:3218931
Created July 31, 2012 17:53
knit2wp
knit2wp <- function(file) {
require(XML)
content <- readLines(file)
content <- htmlTreeParse(content, trim=FALSE)
content <- paste(capture.output(print(content$children$html$children$body,
indent=FALSE, tagSeparator="")),
collapse="\n")
content <- gsub("<?.body>", "", content)
content <- gsub("<?pre><code class=\"r\">", "\\[code lang='r'\\]\\\n",
content)
@dwoll
dwoll / gist:3208449
Created July 30, 2012 17:12
WPshortCode
[code lang='r']...[/code]