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
set nocompatible | |
set encoding=utf-8 | |
set visualbell | |
syntax enable | |
set hidden | |
filetype plugin indent on | |
set showmatch | |
set expandtab | |
set tabstop=8 | |
set softtabstop=2 |
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
# set prompt | |
autoload -U promptinit | |
promptinit | |
export PS1="%n@%M(%~)> " | |
# completion settings | |
autoload -U compinit | |
compinit | |
zstyle ':completion:*:descriptions' format '%U%B%d%b%u' | |
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' | |
# record history and make it available for all open shells |
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
## we need the libraries bookdown, knitr, inline, markdown, pryr | |
system("git clone https://github.com/hadley/adv-r.git") | |
setwd("adv-r") | |
library(knitr) | |
embed_png <- bookdown:::embed_png | |
rmds <- list.files(pattern = "^.*rmd$") | |
sapply(rmds, function(x) knit(x)) | |
cat("---\ntitle: Advanced R\nauthor: Hadley Wickham\nlanguage: en-US\n...\n", | |
file = "front_matter.txt") | |
## assuming we installed pandoc via cabal |
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
rs <- function() { | |
dumpfile <- "~/.rdump" | |
dump <- readLines(dumpfile) | |
cat(paste0("---> ", dump[1], " ... ", tail(dump, 1), "\n")) | |
source(dumpfile, echo = TRUE) | |
system("rtobottom") | |
} |
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(zoo) | |
g_test <- function(x, y, w = 20, l = 1000) { | |
cor_fun <- function(x) cor(x[,1], x[,2]) | |
## benchmark | |
d0 <- data.frame(x, y) | |
c0 <- rollapply(d0, width = w, cor_fun, by.column = FALSE) |
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(rlang) | |
library(tidyr) | |
library(dplyr) | |
library(purrr) | |
spawn_progressbar <- function(x, .name = .pb, .times = 1) { | |
.name <- substitute(.name) | |
n <- nrow(x) * .times | |
eval(substitute(.name <<- dplyr::progress_estimated(n))) | |
x |