Skip to content

Instantly share code, notes, and snippets.

View ctesta01's full-sized avatar
🌱

Christian Testa ctesta01

🌱
View GitHub Profile
---
title: "tikz in Quarto!"
format: html
---
```{r include=FALSE}
# Necessary for using dvisvgm on macOS
# See https://www.andrewheiss.com/blog/2021/08/27/tikz-knitr-html-svg-fun/
Sys.setenv(LIBGS = "/usr/local/share/ghostscript/9.53.3/lib/libgs.dylib.9.53")
@davidtedfordholt
davidtedfordholt / symlog_trans.R
Last active May 31, 2022 18:14
A `scales`/`ggplot2` implementation of the `symlog` transformation
#' symlog transformation
#'
#' `symlog_trans()` transforms data using `log(x)` for `abs(x) > thr`, where
#' `thr` is a tuneable threshold, but leaves the data linear for `abs(x) < thr`.
#' (credit for base code to https://stackoverflow.com/users/1320535/julius-vainora)
#'
#'
#' @param base base of logarithm
#' @param thr numeric threshold for transitioning from log to linear
#' @param scale numeric scaling factor for data
@rmcelreath
rmcelreath / discrete_missingness.R
Created March 8, 2017 10:39
Discrete missing values in Stan
# "impute" missing binary predictor
# really just marginalizes over missingness
# imputed values produced in generated quantities
N <- 1000 # number of cases
N_miss <- 100 # number missing values
x_baserate <- 0.25 # prob x==1 in total sample
a <- 0 # intercept in y ~ N( a+b*x , 1 )
b <- 1 # slope in y ~ N( a+b*x , 1 )
@Jfortin1
Jfortin1 / darken.R
Last active September 2, 2023 20:42
Darken or lighten colors in R
darken <- function(color, factor=1.4){
col <- col2rgb(color)
col <- col/factor
col <- rgb(t(col), maxColorValue=255)
col
}
lighten <- function(color, factor=1.4){
col <- col2rgb(color)
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2024 09:51
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname