Skip to content

Instantly share code, notes, and snippets.

library(hextri)
library(tidyr)
noco = readRDS("/cloud/project/postpi/noco.rds")
truth = readRDS("/cloud/project/postpi/truth.rds")
par = readRDS("/cloud/project/postpi/par_postpi.rds")
nonpar = readRDS("/cloud/project/postpi/nonpar_postpi.rds")
nbins = 20
@jtleek
jtleek / simple-example.R
Created June 11, 2020 19:54
This is an R example of our model.
### Let's simulate some data very simply
## Load libraries
library(ggplot2)
library(dplyr)
library(gam)
library(patchwork)
# Set parameters
n_sample = 100
@jtleek
jtleek / nhanes-flexdashboard.Rmd
Created March 13, 2019 17:50
Example interactive app in R
---
title: "How does your BMI measure up?"
output: flexdashboard::flex_dashboard
runtime: shiny
---
Inputs {.sidebar}
-------------------------------------
```{r}
@jtleek
jtleek / close.Rmd
Created April 21, 2017 01:13
Flexdashboard, its alive!
---
title: "Tabset Column"
runtime: shiny
output: flexdashboard::flex_dashboard
---
```{r setup, include=FALSE}
library(flexdashboard)
@jtleek
jtleek / plot_net.R
Created April 21, 2017 01:12
Plot net working
#library(ggnet)
#library(RkittleBrewer)
#library(network)
plot_net = function(nodes_per_layer,
layer_shape,
connection_type,
stride_length,
layer_color,
node_values,
plot_net = function(nodes_per_layer, layer_shape, connection_type, stride_length){
total_nodes = sum(nodes_per_layer)
adjacency = matrix(0,nrow=total_nodes,ncol=total_nodes)
for(i in seq_along(connection_type)){
source_nodes = 1:nodes_per_layer[i] + (i-1 > 0)*sum(nodes_per_layer[1:(i-1)])
sink_nodes = 1:nodes_per_layer[(i+1)] + (i > 0)*sum(nodes_per_layer[1:i])
nsource = length(source_nodes)
@jtleek
jtleek / jhudsl.R
Created December 19, 2016 17:03
making the jhu dsl gif
library(png)
library(ggforce)
library(animation)
library(tweenr)
jhu_png = readPNG("jhudsl.png")
x = rep(1:510,each=555)
y = rep(1:555,510)
val = jhu_png[,,3]
val = round(val)
@jtleek
jtleek / dumb-resid
Created December 7, 2016 16:16
bootstrapping residuals - the dumb way
f1 = formula(log(cost) ~ date)
lm1 = lm(f1,data=nuclear)
stat = lm1$coeff[2]
resid = lm1$residuals
fit = lm1$fitted.values
n = dim(nuclear)[1]
B = 500
stat0 = rep(0,B)
@jtleek
jtleek / tday.delim
Last active November 25, 2015 17:13
Nov 25 dplyr puzzle solution
col1 col3 col2
t h a
n k s
g i v
i n g
@jtleek
jtleek / puzzlehard_nov25_2015.delim
Last active November 25, 2015 17:08
November 25th advanced dplyr puzzle
col3 col2 col4 col1
h b t t
i w i g
k t g n
n h n i