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 ;
// [[Rcpp::plugins(cpp11)]]
inline uint64_t as_uint64_t(double x){
return *reinterpret_cast<uint64_t*>( &x ) ;
}
inline uint64_t quiet_na(){
/* 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>
#include <Rcpp.h>
using namespace Rcpp ;
// [[Rcpp::plugins(cpp11)]]
template <int RTYPE>
Vector<RTYPE> rotate_impl( Vector<RTYPE> x, int pivot ){
auto n = x.size() ;
Vector<RTYPE> res = no_init(n) ;
library(tidyverse)
library(rvest)
library(glue)
inclusivise <- function( mot = "étudiant" ){
url <- glue( "http://www.larousse.fr/dictionnaires/rechercher/?q={mot}&l=francais&culture=" )
mots <- url %>%
read_html() %>%
html_node(".AdresseDefinition") %>%
library(purrr)
library(dplyr)
na_set <- function(x, p){
p <- as_mapper(p)
x[p(x)] <- NA
x
}
# or something like this using case_when
@romainfrancois
romainfrancois / nanana.R
Created December 14, 2017 13:12
history if is.na
library(tidyverse)
library(glue)
# i have my reasons, please dont burn my computer
setwd("~/git/r-source")
extract_isna <- function(.){
cat( "\r", . )
invisible( system(paste0('git checkout -q -f ', .)) )
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(tidyverse)
library(rtweet)
library(glue)
get_timeline("LucyStats", n = 100) %>%
pull(text) %>%
str_extract_all( emo::ji_rx ) %>%
flatten_chr() %>%
table() %>%
enframe() %>%
library(rtweet)
library(tidyverse)
tweets <- get_timeline("romain_francois", n = 5000)
tweets %>%
pull(text) %>%
str_extract_all(emo::ji_rx) %>%
flatten_chr() %>%
table() %>%
enframe(name = "emoji") %>%
library(rtweet)
library(tidyverse)
library(emo)
library(lubridate)
tweets <- get_timeline("dataandme", include_rts = FALSE, n = 5000)
tweets %>%
mutate(
date = as_date(created_at),