This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
logit <- function(u) log(u)-log(1-u) | |
raise_to_pow <- function(fun, pname_pow=".pow"){ | |
eval(parse(text=gsub(pattern=".pow", replacement=pname_pow, | |
"function(u, .pow=1, ...) fun(u,...)^(.pow)"))) | |
} | |
powlogit <- logit %>% raise_to_pow(pname_pow="e") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rstan) | |
stanmodelcode <- " | |
data { | |
int<lower=0> N; | |
int<lower=0> y[N]; | |
} | |
parameters { | |
real<lower=0.00001> Theta; | |
} | |
model { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(minisvg) | |
lightpurple <- "#c0c0f2" | |
darkpurple <- "#9596ce" | |
x <- 5 | |
s <- x*10 | |
a <- x*sqrt(2) | |
chkrs_pat <- stag$pattern(width=2*s, height=2*s, id = 'chkrs_pattern', | |
patternUnits = 'userSpaceOnUse', | |
stag$rect(x=0, y=0, width =s, height = s, fill=lightpurple), | |
stag$rect(x=s, y=0, width =s, height = s, fill=darkpurple), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidybayes) | |
library(ggplot2) | |
library(hrbrthemes) | |
m <- 100 | |
s <- 10 | |
dist_df <- tibble::tibble(y=seq.int(0.01,0.99, by=0.05), | |
arg1_mean=qlnorm(p=y,meanlog=log(m), sdlog=log(s)), | |
arg2_sd=abs(0.5-y+0.1)*400+100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is.unset<-function(x) | |
x==as.list(alist(a=))[[1]] | |
is.nameempty <- function(x){ | |
nx <- names(x) | |
if(is.null(nx)) | |
return(rep(TRUE, length(x))) | |
is.na(nx) | nx=="" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: 'Tables with references' | |
author: dmi3kno | |
date: '2018-01-25' | |
abstract: | | |
My goal was to prepare a minimum reproducible example. | |
output: | |
pdf_document: | |
citation_package: natbib | |
keep_md: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magick) | |
library(hocr) | |
library(bunny) | |
library(bbx) | |
library(dplyr) | |
img <- image_read("https://pbs.twimg.com/media/EXKzsiAWoAYH9Pv?format=png") | |
img_bw <- img %>% | |
image_threshold("white", threshold = "5%") %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tips and ideas from | |
# https://stackoverflow.com/questions/5546346/how-to-place-and-center-text-in-an-svg-rectangle | |
library(minisvg) | |
doc <- svg_doc(width = 600, height = 600) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Centered text in circle | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magick) | |
library(bunny) | |
# function for calculating mode | |
mode_n <- function(x, n=1){ | |
res <- with(rle(sort(x)), values[order(lengths, decreasing = TRUE)]) | |
res[n] | |
} | |
img <- image_read("EWOwbehXkAgxeHO.jpeg") %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(brms) | |
library(tidybayes) | |
mpg_model <- brm( | |
bf(hwy ~ 0 + drv), | |
data = mpg, | |
prior = c( | |
set_prior("normal(20, 3)", class = "b", lb = 0, ub = 40), | |
set_prior("student_t(3, 0, 10)", class = "sigma") |
NewerOlder