Skip to content

Instantly share code, notes, and snippets.

View plots-for-postpi.R
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 Jun 11, 2020
This is an R example of our model.
View simple-example.R
### 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 Mar 13, 2019
Example interactive app in R
View nhanes-flexdashboard.Rmd
---
title: "How does your BMI measure up?"
output: flexdashboard::flex_dashboard
runtime: shiny
---
Inputs {.sidebar}
-------------------------------------
```{r}
@jtleek
jtleek / close.Rmd
Created Apr 21, 2017
Flexdashboard, its alive!
View close.Rmd
---
title: "Tabset Column"
runtime: shiny
output: flexdashboard::flex_dashboard
---
```{r setup, include=FALSE}
library(flexdashboard)
@jtleek
jtleek / plot_net.R
Created Apr 21, 2017
Plot net working
View plot_net.R
#library(ggnet)
#library(RkittleBrewer)
#library(network)
plot_net = function(nodes_per_layer,
layer_shape,
connection_type,
stride_length,
layer_color,
node_values,
View forsean.R
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 Dec 19, 2016
making the jhu dsl gif
View jhudsl.R
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 Dec 7, 2016
bootstrapping residuals - the dumb way
View dumb-resid
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 Nov 25, 2015
Nov 25 dplyr puzzle solution
View tday.delim
col1 col3 col2
t h a
n k s
g i v
i n g
@jtleek
jtleek / puzzlehard_nov25_2015.delim
Last active Nov 25, 2015
November 25th advanced dplyr puzzle
View puzzlehard_nov25_2015.delim
col3 col2 col4 col1
h b t t
i w i g
k t g n
n h n i