Skip to content

Instantly share code, notes, and snippets.

View oliviergimenez's full-sized avatar
🏠
Working from home

Olivier Gimenez oliviergimenez

🏠
Working from home
View GitHub Profile
@bbolker
bbolker / morganstanley_cursed_mixed.R
Created March 23, 2022 23:39
mixed model for 'cursed' Morgan Stanley data
## setup from https://www.tjmahr.com/morgan-stanley-cursed-covid-plot/
library(tidyverse)
theme_set(theme_bw())
library(lme4)
library(ggeffects)
library(colorspace)
library(directlabels)
# a helper function to download the data from github
@marcosci
marcosci / olympus_hex.R
Created November 5, 2021 12:32
Hexagonal Rayshading
library(LaCroixColoR)
library(sf)
library(fasterize)
library(rayshader)
library(raster)
library(exactextractr)
library(rayrender)
# load raster into R
elevation <- raster("Olympus_Mons_ortho-image.tif")
library(tidyverse)

# load in source_rmd()
devtools::source_gist("https://gist.github.com/noamross/a549ee50e8a4fd68b8b1")
#> Sourcing https://gist.githubusercontent.com/noamross/a549ee50e8a4fd68b8b1/raw/40960d8280438b7e2e8d6502f3c1d4ad348caeb6/source_rmd.R
#> SHA-1 hash of file is 624ae941e51dee522994e014928448170cedf1a3
# Also could have used solution here: 
# https://stackoverflow.com/questions/10966109/how-to-source-r-markdown-file-like-sourcemyfile-r
@coulmont
coulmont / deces_polaire_anime.R
Created December 2, 2020 13:02
deces en france, coordonnées polaires, version animée
# ajout des informations pour l'animation
# ---------------------------------------
library(gganimate)
library(broom)
dc <- bind_rows(dc_jour,dc_insee_jour,deces_ecdc,deces_insee_provisoires)
# on démarre du fichier dc utilisé pour le graphique surmortalité

App Install Plan

Critical

library(glmmTMB)
library(mgcv)
#########################################################################
## Function to create prediction matrices from mgcv for glmmTMB
## from ?mgcv::smooth2random
########################################################################
s2rPred <- function(sm,re,data) {
## Function to aid prediction from smooths represented as type==2
## random effects. re must be the result of smooth2random(sm,...,type=2).
@d-qn
d-qn / lausanne_OSM_city_map.R
Last active October 15, 2020 16:45
Make a minimal arty city map with R and openstreetmap data
library(tidyverse)
library(sf)
library(osmdata) # to get openstreetmap geo data
# settings
bb <- getbb('Lausanne, Switzerland') # define the bbox, will be used to fetch OSM data within that box
dest_proj <- 2056
# OSM overpass query
q <- opq(bbox = bb)
@gavinsimpson
gavinsimpson / animated-basis-functions.R
Created May 7, 2020 19:18
Animated spline basis functions
## plots and animations of how basis functions are used to make
## splines and how these are fitted to data
library('ggplot2')
library('tibble')
library('tidyr')
library('dplyr')
library('mgcv')
library('mvnfast')
library('purrr')
@statnmap
statnmap / df_to_stack.R
Created October 31, 2019 07:38
Transform multiple layer dataframe raster into stack
library(raster)
# remotes::install_github("statnmap/cartomisc")
library(cartomisc)
library(dplyr)
library(purrr)
# Create original raster
fn <- system.file("external/test.grd", package="raster")
s <- stack(fn, fn)
library(imager)
library(tidyverse)
URL1<-"1280px-CLaude_Monet_037.jpg"
IMAGE <- imager::load.image(URL1)
df1 <- as.data.frame(IMAGE,wide="c") %>% mutate(rgb.val=rgb(c.1,c.2,c.3))
df1<-df1%>%mutate(xNtile=ntile(x,60),
yNtile=ntile(y,60))%>%
group_by(xNtile,y)%>%
mutate(Xrang=rank(-x),