Skip to content

Instantly share code, notes, and snippets.

View romainfrancois's full-sized avatar
🎉
tada⬢science ⬡⬡ ex(Posit/RStudio, ThinkR, Mango Solutions)

Romain François romainfrancois

🎉
tada⬢science ⬡⬡ ex(Posit/RStudio, ThinkR, Mango Solutions)
View GitHub Profile
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))
/* 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>
@romainfrancois
romainfrancois / install-mini.R
Created August 29, 2017 13:41 — forked from VincentGuyader/install-mini.R
configuration poste R
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)
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)
#!/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!!!
#
# ----------------------------------------------------------------
library(Rcpp)
library(microbenchmark)
vectorized <- function() {
a <- c(1, 1)
b <- c(2, 2)
for (i in 1:1000000) {
x <- a + b
}
#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++) {