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
#include <Rcpp.h>
using namespace Rcpp ;
class abc {
public:
abc( SEXP x ) : data(x){}
inline operator SEXP() const {
return data ;
}
@romainfrancois
romainfrancois / mario.R
Last active August 29, 2015 14:04
mario beep on OSX
# The code below will probably only work on Linux and requires VLC on the path.
library(beepr)
library(stringr)
play_vlc <- function(fname) {
system(paste("open -a vlc --args --no-loop --no-repeat --playlist-autostart --no-media-library", fname),
ignore.stdout = TRUE, ignore.stderr=TRUE,wait = FALSE)
}
# Plays the mario theme while expr is executing, plays the flag pole jingle when the execution have finished.
```
ir <- structure( iris, class = c("foo", "data.frame") )
rbind.foo <- function(...) rbind.data.frame(...)
rbind(ir,iris)
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#ir Numeric,150 Numeric,150 Numeric,150 Numeric,150 factor,150
#iris Numeric,150 Numeric,150 Numeric,150 Numeric,150 factor,150
```
So apparently we get the same as :
@romainfrancois
romainfrancois / forbidden.c
Created September 22, 2014 10:02
get some forbidden C/R API fruits
#include <Rinternals.h>
#include <Rinterface.h>
extern void* R_GlobalContext ;
#define R_NO_REMAP
#define USE_RINTERNALS
#include <R.h>
#include <Rinternals.h>
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)
library(rvest)
library(purrr)
library(tibble)
library(dplyr)
library(stringr)
attendees <- function(page) {
extract <- function(class) html_node( persons, class ) %>% html_text() %>% str_trim()
url <- paste0( 'https://user2017.sched.com/directory/attendees/', page )
library(tidyverse)
library(lubridate)
library(emoGG)
lexie <- tribble( ~date, ~weight,
"2017-07-12", 3.460,
"2017-07-13", 3.200,
"2017-07-14", 3.100,
"2017-07-15", 3.200,
"2017-07-16", 3.250,
library(emo)
library(stringr)
library(purrr)
emoji_name <- emo:::emoji_name
emoji_keyword <- emo:::emoji_keyword
maybe_emoji <- function( keyword ){
if (keyword %in% names(emoji_name)) {
@romainfrancois
romainfrancois / hack.R
Created August 17, 2017 10:10
emoji completion hack
.original.rs.getCompletionsFile <- .rs.getCompletionsFile
assign( ".rs.getCompletionsFile", function (token, path = getwd(), quote = FALSE, directoriesOnly = FALSE) {
if( grepl( ".*[:]", token ) ){
tok <- sub( ".*[:]", "", token)
start <- sub( "[:].*", "", token)
.rs.makeCompletions(
token = token , results = paste0( start, emo::ji_completion(tok) ) ,
excludeOtherCompletions = TRUE, type= .rs.acCompletionTypes$STRING,
quote = FALSE
@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)