Skip to content

Instantly share code, notes, and snippets.

Avatar
🪲

Romain François romainfrancois

🪲
View GitHub Profile
View brew_install_arrow
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 Jun 29, 2020
code used in my dplyr talk at e-Rum 2020
View dplyr_erum.R
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)
View example.R
library(dplyr)
library(purrr)
df <- tribble(
~x, ~y,
"a", "b",
"c", "b",
"b", "a",
"b", "b",
"a", "a"
View fetedelamusique.R
suppressMessages(library(tidyverse))
musique <- jsonlite::read_json("https://www.data.gouv.fr/fr/datasets/r/0dba0390-5eba-401f-aae5-933243c0b163", simplifyDataFrame = TRUE)$fields
musique %>%
pull("keywords_fr") %>%
str_split(";") %>%
flatten_chr() %>%
table() %>%
enframe() %>%
View dctweet.R
library(tidyverse)
library(rtweet)
library(glue)
library(rtweet)
# likes <- <chr vector of accounts that liked the tweet>
# retweets <- <chr vector of accounts that retweeted the tweet>
data <- tibble(
user = c(likes, retweets),
View rprofile.R
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")
View slam.R
library(purrr)
library(rap)
library(gapminder)
library(dplyr, warn.conflicts = FALSE)
oceania <- gapminder::gapminder %>%
filter(continent == "Oceania") %>%
mutate(yr1952 = year - 1952) %>%
select(-continent) %>%
View named_group_split.R
library(dplyr, warn.conflicts = FALSE)
library(purrr)
named_group_split <- function(...) {
data <- group_by(...)
names <- group_keys(data) %>%
map(as.character) %>%
reduce(paste, sep = "~~")
View summarise_all.R
library(dplyr, warn.conflicts = FALSE)
library(purrr)
expressions <- function(vars, funs) {
#' make_expr("mpg", mean)
make_expr <- function(var, fun) {
expr((!!fun)(!!sym(var)))
}
@romainfrancois
romainfrancois / distinct2.r
Last active Dec 19, 2018
distinct with incomparable
View distinct2.r
library(dplyr, warn.conflicts = FALSE)
distinct2 <- function(df, predicate_incomparable, ...) {
predicate_incomparable <- enquo(predicate_incomparable)
# rows for which the predicate os true for at least one variable
incomparables <- filter_all(df, any_vars(!!predicate_incomparable))
# rows for which the predicate is false for all variables
comparables <- filter_all(df, all_vars(!(!!predicate_incomparable)))