Skip to content

Instantly share code, notes, and snippets.

View PMassicotte's full-sized avatar
🌟
Working from home

Philippe Massicotte PMassicotte

🌟
Working from home
View GitHub Profile
@PMassicotte
PMassicotte / arrow.R
Created May 3, 2024 14:54
Arrow build log
[ins] r$> install.packages("arrow", repos = "https://cran.rstudio.com")
Installing package into ‘/home/filoche/R/x86_64-pc-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/arrow_15.0.1.tar.gz'
Content type 'application/x-gzip' length 4373377 bytes (4.2 MB)
==================================================
downloaded 4.2 MB
* installing *source* package ‘arrow’ ...
** package ‘arrow’ successfully unpacked and MD5 sums checked
@PMassicotte
PMassicotte / myraster.R
Created February 27, 2024 18:47
Rasterizing code
library(tidyverse)
library(terra)
library(tidync)
raster_template <- rast(
xmin = -71.1,
xmax = -50.7,
ymin = 39.05,
ymax = 51.45,
resolution = 0.05,
@PMassicotte
PMassicotte / .R
Created January 5, 2024 22:30
duckdb/sf
``` r
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.0, PROJ 9.2.0; sf_use_s2() is TRUE
library(duckdb)
#> Loading required package: DBI
con <- dbConnect(duckdb())
dbExecute(con, "INSTALL spatial; LOAD spatial;")
#> [1] 0
@PMassicotte
PMassicotte / test_tiledb.R
Created March 28, 2022 11:58
Playing around with tiledb
library(dplyr)
library(tiledb)
files <- fs::dir_ls("~/Desktop/ppz/")
uri <- "~/Desktop/tiledb"
# unlink(uri, recursive = TRUE)
dom <- tiledb_domain(dims = c(
tiledb_dim("longitude", c(-180.0, 180.0), type = "FLOAT64"),
sapply(fread(file, nrows = 53), class)
# https://git.io/JtNlE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
ctd <- ctd %>%
group_by(station, cast, date_time, longitude, latitude)
ctd
tic()
res <- ctd %>%
mutate(across(
c(flor_mg_m3, sigt_kg_m3),
~ zoo::rollmedian(.x, k = 11, fill = NA, align = "center"),
ctd
tic()
ctd %>%
group_by(station, cast, date_time, longitude, latitude) %>%
mutate(across(
c(flor_mg_m3, sigt_kg_m3),
~ zoo::rollmedian(.x, k = 11, fill = NA, align = "center"),
.names = "{.col}_rollmedian"
))
ctd
tic()
ctd %>%
group_by(station, cast, date_time, longitude, latitude) %>%
mutate(across(
c(flor_mg_m3, sigt_kg_m3),
~ zoo::rollmedian(.x, k = 11, fill = NA, align = "center"),
.names = "{.col}_rollmedian"
))
library(tidyverse)
library(curl)
library(ggpmthemes)
library(ggtext)
theme_set(theme_exo())
file <-
"ftp://sidads.colorado.edu/DATASETS/NOAA/G02135/north/daily/data/N_seaice_extent_daily_v3.0.csv"