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
@romainfrancois
romainfrancois / output.txt
Created December 14, 2013 14:07
Extract promises and their environments from ...
> f <- function(...) {
+ promises(environment())
+ }
> g <- function(x = 3, ...) {
+ z <- 4
+ f(z = z, ..., x = x)
+ }
> h <- function(..., a = 2) {
@romainfrancois
romainfrancois / bench.R
Created November 25, 2013 17:16
Decomposing `build_index_cpp`
require(dplyr)
require(Rcpp)
require(microbenchmark)
# from the cran-logs-dply repo
logs <- readRDS("logs.rds")
# system.time( { by_day <- group_by(logs, date) } )
sourceCpp( "timings.cpp" )
@romainfrancois
romainfrancois / README.md
Created October 29, 2013 08:10
Log for last travis build of a project

This uses siesta to pull from travis the log for the last build of a given project.

$ travis_log hadley/dplyr | tail -n30
Le chargement a nécessité le package : methods
Le chargement a nécessité le package : siesta
* checking package vignettes in ‘inst/doc’ ... WARNING
Package vignettes without corresponding PDF/HTML:
   ‘benchmark-baseball.Rmd’
 ‘databases.Rmd’
@romainfrancois
romainfrancois / README.md
Last active December 26, 2015 16:19
getting github issues for a given repo

Simple R script that grabs the opened issues from a github repo :

$ github_issues hadley/dplyr
   number           user                                                         title                labels
1      98         hadley                                   Setup databases with travis           enhancement
2      97         hadley                                               Unique operator           enhancement
3      96         hadley                           Implement right join and outer join           enhancement
4      95 romainfrancois                                             Hybrid evaluation enhancement, internal
5      94         hadley                 Make sure all vignettes work from R CMD check                   bug
@romainfrancois
romainfrancois / bench-sorted.cpp
Last active December 26, 2015 11:49
Benchmark sorted vs. unsorted grouped summarise
#include <dplyr.h>
// [[Rcpp::depends(BH,dplyr)]]
using namespace Rcpp ;
using namespace dplyr ;
class IndexHelper {
public:
IndexHelper( int pos_, int n_) : pos(pos_), n(n_){}
@romainfrancois
romainfrancois / output.txt
Created October 24, 2013 16:25
using SETLENGTH to fool R about the size of a vector
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
x = <0x1038ff8a0>, dataptr = <0x1038ff8c8>
@romainfrancois
romainfrancois / gist:7117691
Last active April 12, 2020 17:22
create list with more than 20 elements (different syntax)
#include <Rcpp.h>
using namespace Rcpp ;
template <typename T>
inline void set_item_impl( List& target, int i, const T& obj, CharacterVector& names, traits::true_type ){
target[i] = obj.object ;
names[i] = obj.name ;
}
template <typename T>
@romainfrancois
romainfrancois / biglist.cpp
Created October 23, 2013 12:15
create lists with more than 20 elements
#include <Rcpp.h>
using namespace Rcpp ;
template <typename T>
inline void set_item_impl( List& target, int i, const T& obj, CharacterVector& names, traits::true_type ){
target[i] = obj.object ;
names[i] = obj.name ;
}
template <typename T>
@romainfrancois
romainfrancois / gist:6981372
Last active December 25, 2015 13:09
Reading the internal function table
#include <Rcpp.h>
using namespace Rcpp;
typedef SEXP (*CCODE)(SEXP, SEXP, SEXP, SEXP);
/* Information for Deparsing Expressions */
typedef enum {
PP_INVALID = 0,
PP_ASSIGN = 1,
PP_ASSIGN2 = 2,
#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++) {