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(gapminder) | |
library(tidyverse) | |
library(zap) | |
library(broom) | |
# gapminder data for Asia only | |
gap <- gapminder %>% | |
filter(continent == "Asia") %>% | |
mutate(yr1952 = year - 1952) %>% | |
mutate(country = fct_reorder2(country, .x = year, .y = lifeExp)) |
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
/* clang++ -std=c++14 timing.cc -o timing -g -Wall -O3 */ | |
#include <time.h> | |
#include <math.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <locale.h> | |
#include <algorithm> |
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
percent <- function(x, digits = 2, format = "f", ...) { | |
paste0(formatC(100 * x, format = format, digits = digits, ...), "%") | |
} | |
mon_print <- function(synth){ | |
N <- nrow(synth) | |
if( is.null(N)){ | |
N<-1 | |
synth <- | |
matrix(synth,nrow=1) | |
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(Rcpp) | |
library(microbenchmark) | |
vectorized <- function() { | |
a <- c(1, 1) | |
b <- c(2, 2) | |
for (i in 1:1000000) { | |
x <- a + b | |
} |
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
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
NumericVector rowApply0(NumericMatrix& x, const Function& FUN) | |
{ | |
int n = x.nrow(); | |
NumericVector result = no_init(n); | |
for (int r = 0; r < n; r++) { |
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(purrr) | |
library(github) # install_github("cscheid/rgithub") | |
library(dplyr) | |
library(stringr) | |
library(magrittr) | |
# Download issues --------------------------------------------------------- | |
ctx <- interactive.login("56b637a5baffac62cad9", "8e107541ae1791259e9987d544ca568633da2ebf") | |
issues1 <- get.repository.issues("hadley", "dplyr", per_page = 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
#!/usr/bin/R | |
# this script is poorly-written, so use at your own risk. | |
# --------------------------------------------------------------- | |
# | |
# THIS HAS A VERY GOOD CHANCE OF COMPLETELY DESTROYING YOUR REPO; | |
# ONLY RUN THIS ON A COPY OF THE REPO!!! | |
# | |
# ---------------------------------------------------------------- |