Skip to content

Instantly share code, notes, and snippets.

View GuillaumePressiat's full-sized avatar

GuillaumePressiat

View GitHub Profile

Tutoriel : la non-standard evaluation avec rlang

La tidy evaluation est le cadre que propose rlang pour manipuler des expressions plutôt que des valeurs. C'est ce qui permet à dplyr::filter(df, age > 65) de fonctionner alors que age n'existe pas dans l'environnement global. Ce tutoriel couvre les fonctions essentielles, dans l'ordre où on en a réellement besoin quand on écrit ses propres fonctions autour du tidyverse.

library(rlang)
library(dplyr)

1. Le problème de départ

@GuillaumePressiat
GuillaumePressiat / main.rs
Created May 27, 2025 20:10 — forked from deanm0000/main.rs
polars to postgres via tokio::postgres copy binary in rust
#[tokio::main]
async fn main() {
let mut client = make_postgres().await; // tokio_postgres::connect with spawn
let transaction = client.transaction().await.unwrap();
// make an example df
let utc=PlSmallStr::from_str("UTC");
let ava = AnyValue::Datetime(Utc
.with_ymd_and_hms(2010, 1, 1, 1, 0, 0)
.unwrap()
@GuillaumePressiat
GuillaumePressiat / pmsi_rust_rsa.rs
Last active December 5, 2023 23:31
rust pola.rs example for fwf file
use polars::prelude::*;
use std::{
env
};
pub fn main(){
configure_the_environment();
@GuillaumePressiat
GuillaumePressiat / main_tantivy_test.rs
Created November 26, 2023 21:53
Tantivy test en Rust, slop, phraseQuery, fuzzyTerm
#[macro_use]
extern crate tantivy;
use tantivy::query::QueryParser;
use tantivy::schema::*;
use tantivy::ReloadPolicy;
use tempfile::TempDir;
use tantivy::query::FuzzyTermQuery;
use tantivy::query::PhraseQuery;
use tantivy::query::TermQuery;
use tantivy::collector::{Count, TopDocs};
@GuillaumePressiat
GuillaumePressiat / underscrape_and_RSelenium.R
Last active August 14, 2023 21:55
Using Selenium in R to scrape JS tables
# https://stackoverflow.com/q/67021563/10527496
# java -jar selenium-server-standalone-3.9.1.jar
library(RSelenium)
library(tidyverse)
library(rvest)
@GuillaumePressiat
GuillaumePressiat / municipales_lecture_data_.R
Created February 18, 2021 21:18
Lire et passer fichier data.gouv ministère intérieur commune > 1000 hab. 1er tour
library(readr)
library(dplyr)
# 1er tour
# https://www.data.gouv.fr/fr/datasets/elections-municipales-2020-resultats-1er-tour/#_
u <- read_tsv('~/Downloads/2020-05-18-resultats-communes-de-1000-et-plus.txt',
locale = locale(encoding = "latin1"),
col_types = cols(
.default = col_character(),
`Code du département` = col_double(),
@GuillaumePressiat
GuillaumePressiat / covid_sidep_sursaud_down.R
Last active October 14, 2020 08:47
Collecter les csv covid SI-DEP et SURSAUD de SPF depuis data.gouv.fr en interrogeant son api, résultat un fichier excel, ici filtré sur la Bretagne
library(dplyr, warn.conflicts = FALSE)
liste_url <- list(
indicateurs = list(url_web = "https://www.data.gouv.fr/fr/datasets/indicateurs-de-suivi-de-lepidemie-de-covid-19/",
url_stable = "https://www.data.gouv.fr/fr/datasets/r/4acad602-d8b1-4516-bc71-7d5574d5f33e",
url_api = "https://www.data.gouv.fr/api/1/datasets/5ee9df5003284f565d561278/",
titre = "Indicateurs de suivi de l’épidémie de COVID-19",
# file_pattern = "indicateurs-covid19-dep",
file_pattern = "indicateurs-open-data-dep",
delim = ",",
library(sf)
library(spatstat)
library(sp)
library(maptools)
library(raster)
library(cartography)
library(SpatialPosition)
## import dataset
feat <- sf::st_read("https://gist.githubusercontent.com/rCarto/747164575e3f216a123c3092d0ce9162/raw/f12390464f255b5f9760c577ab6bf5456cf61a40/iris75.geojson")
install_github_with_proxy <- function(package = "GuillaumePressiat/pmeasyr", proxy_port = "<host>:<port>/", ...){
u <- rstudioapi::askForPassword('User for proxy authentification')
p <- rstudioapi::askForPassword('Password for proxy authentification')
Sys.setenv(ALL_PROXY = paste0("http://", u, ":", p, "@", proxy_port))
remotes::install_github(package, ...)
}
library(leaflet)
library(sf)
library(rmapshaper)
library(dplyr, warn.conflicts = FALSE)
library(smoothr)
library(shiny)
u <- httr::GET('https://www.data.gouv.fr/api/1/datasets/5e7e104ace2080d9162b61d8/')
url_search <- httr::content(u)$resources