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 / internal.R
Created February 17, 2014 16:38
Show what's in .Internal function
library("httr")
library("rjson")
internal <- function(fun){
names.c <- content( GET("https://raw2.github.com/wch/r-source/trunk/src/main/names.c") )
names.c <- strsplit( names.c, "\\n" )[[1L]]
rx <- sprintf('^[{]"%s"', fun )
match <- grep( rx, names.c)
if( length(match) != 1L ){
@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@sherlox /tmp % brew install apache-arrow --HEAD -v
==> Downloading https://github.com/apache/arrow/commit/ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch?full_index=1
Already downloaded: /Users/romainfrancois/Library/Caches/Homebrew/downloads/bebaf2a7625dae0afc3e8aca8f0a05cd8f341811c2661341315d537706ac2cfc--ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch
==> Verifying bebaf2a7625dae0afc3e8aca8f0a05cd8f341811c2661341315d537706ac2cfc--ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch checksum
==> Cloning https://github.com/apache/arrow.git
Updating /Users/romainfrancois/Library/Caches/Homebrew/apache-arrow--git
git config remote.origin.url https://github.com/apache/arrow.git
git config remote.origin.fetch \+refs/heads/master:refs/remotes/origin/master
git config remote.origin.tagOpt --no-tags
git fetch origin
@romainfrancois
romainfrancois / dplyr_erum.R
Created June 29, 2020 07:17
code used in my dplyr talk at e-Rum 2020
library(dplyr, warn.conflicts = FALSE)
library(palmerpenguins)
# multiple rows
penguins %>%
group_by(species) %>%
summarise(
prob = c(.25, .75),
length = quantile(bill_length_mm, prob, na.rm = TRUE),
depth = quantile(bill_depth_mm, prob, na.rm = TRUE)
@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>
if(interactive()) {
.__Rprofile_env__. <- new.env(parent = emptyenv())
.__Rprofile_env__.[["install"]] <- pak::pkg_install
attach(.__Rprofile_env__.)
library(usethis, warn.conflicts = FALSE)
library(conflicted)
conflict_prefer("filter", "dplyr")
conflict_prefer("sql", "dbplyr")
library(purrr)
library(assertthat)
let <- function(...) quos(...)
`:=` <- function(left, right){
names <- map_chr(left, quo_name)
assert_that( length(right) >= length(names) )
env <- parent.frame()
for( i in seq_along(names) ){
library(dplyr, warn.conflicts = FALSE)
library(purrr)
expressions <- function(vars, funs) {
#' make_expr("mpg", mean)
make_expr <- function(var, fun) {
expr((!!fun)(!!sym(var)))
}