I hereby claim:
- I am statwonk on github.
- I am statwonk (https://keybase.io/statwonk) on keybase.
- I have a public key ASBKY0yAKx1KghVEq7DmzhrFWAIZn94O-vhQHcjU9Wwz-go
To claim this, I am signing this object:
library(shiny) | |
iris <- datasets::iris | |
names(iris) <- gsub('[/.]','_',tolower(names(iris))) | |
shinyServer( | |
function(input, output) { | |
output$json <- reactive({ | |
paste('<script>data=', | |
RJSONIO::toJSON(iris[iris$species == input$species,], byrow=T, colNames=T), | |
';console.log(data[0]);', # print 1 data line to console |
library(shiny) | |
library(DiagrammeR) | |
library(magrittr) | |
shinyServer(function(input, output) { | |
output$diagram_plot <- renderDiagrammeR({ | |
graph <- | |
create_graph() %>% | |
set_graph_name("Boxes and Circles") %>% | |
set_graph_time() %>% |
function (pkgInfo, quietly = FALSE, lib.loc = NULL, useImports = FALSE) | |
{ | |
.findVersion <- function(pkg, lib.loc = NULL) { | |
pfile <- system.file("Meta", "package.rds", package = pkg, | |
lib.loc = lib.loc) | |
if (nzchar(pfile)) | |
as.numeric_version(readRDS(pfile)$DESCRIPTION["Version"]) | |
else NULL | |
} | |
.findAllVersions <- function(pkg, lib.loc = NULL) { |
function (package, help, pos = 2, lib.loc = NULL, character.only = FALSE, | |
logical.return = FALSE, warn.conflicts = TRUE, quietly = FALSE, | |
verbose = getOption("verbose")) | |
{ | |
testRversion <- function(pkgInfo, pkgname, pkgpath) { | |
if (is.null(built <- pkgInfo$Built)) | |
stop(gettextf("package %s has not been installed properly\n", | |
sQuote(pkgname)), call. = FALSE, domain = NA) | |
R_version_built_under <- as.numeric_version(built$R) | |
if (R_version_built_under < "3.0.0") |
suppressPackageStartupMessages({ | |
library(dplyr) | |
library(ggplot2) | |
library(purrr) | |
}) | |
exp_likelihood <- function(x, lambda) { | |
(lambda^length(x))*exp(-lambda*length(x)*mean(x)) | |
} | |
seq_len(1e2) %>% | |
lapply(function(i) { |
I hereby claim:
To claim this, I am signing this object:
library(survival) | |
library(Hmisc) | |
# 1. a weibull random number generator, see http://statwonk.com/weibull.html | |
rweibull_cens <- function(n, shape, scale) { | |
# will happen to see the death time first or censoring? | |
rweibull(n, shape = shape, scale = scale) -> a_random_death_time | |
rweibull(n, shape = shape, scale = scale) -> a_random_censor_time | |
pmin(a_random_censor_time, a_random_death_time) -> observed_time |
library(tidyverse) | |
# Cumulative density functions | |
?hist | |
# built in datasets | |
str(mtcars) | |
head(mtcars) |
library(tidyverse) | |
library(lme4) | |
library(broom) | |
N <- 1e4 | |
generate_data <- function() { | |
tibble( | |
intercept = 1, | |
pretreatment_var = case_when(rbinom(N, 1, p = 0.5) == 1 ~ 0.5, TRUE ~ -0.5), |