Skip to content

Instantly share code, notes, and snippets.

View gvdr's full-sized avatar

Giulio Valentino Dalla Riva gvdr

View GitHub Profile
@gvdr
gvdr / get_codelists.jl
Created June 26, 2025 22:59
Extract SDMX codelists from a PDH .Stat dataflow api url using Julia
# it assumes you are in an environment with the following packages installed
using EzXML # for XML navigation
using HTTP # for querying PDH .Stat api
using DataFrames, Tidier # to operate with Dataframes
"""
get_parent_id(code_node::EzXML.Node) -> Union{String, Missing}
Finds the parent of a code by looking for the <structure:Parent>/<Ref> element
@gvdr
gvdr / extract_objects.R
Created June 26, 2025 05:03
Extract Codelists from PDH .Stat dataflows with R and RSDMX
library(tidyverse)
library(rsdmx)
#' Get All Codelist Mappings from an SDMX URL or File
#'
#' This function takes a source URL or filepath, reads the SDMX structural information,
#' and extracts a mapping of all dimensions and attributes to their
#' corresponding codelist IDs.
#'
#' @param sdmx_source A string containing the URL or filepath to an the dataflow structure
@gvdr
gvdr / Manifest.toml
Created December 8, 2023 02:17
elementary project and manifest for AUSDM23 tutorial
# This file is machine-generated - editing it directly is not advised
julia_version = "1.9.4"
manifest_format = "2.0"
project_hash = "854267dae88bd3bbd6557a02d62085af68e79521"
[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@gvdr
gvdr / square_diagonality.jl
Last active November 9, 2020 23:52
exploring the diagonality score of square matrices
### A Pluto.jl notebook ###
# v0.12.4
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
library(tidyverse)
library(readxl)
library(janitor)
library(ggridges)
# let's download the table
download.file("https://www.istat.it/it/files//2020/03/Tavola-sintetica-decessi.xlsx",
"Tavola-sintetica-decessi.xlsx")
# we prefer to work with clean names
# I'd live to use the usual mathematical notations to do summatories and productories
# turns out, in Julia it's pretty easy as long as we keep things simple
# as we can just embellish the already defined sum() and prod() function
# only tweak is choosing a negative step if we want to sum from i = N to M with N>M
# for the summatory:
function ∑(f::T;from::Int, to::Int) where T <: Function
step_sum = from > to ? 1 : -1
sum(safer(f), range(from, stop = to, step = step_sum))
end
using StatsBase, Random, Distributions
using Plots
# parameters for the simulations
blocks = 70000; # Number of ticket blocks
tickets = 7000000; # Number of tickets
draws = 200; # Number of prizes
K = 100000; # Number of lotteries to simulate at each replication
R = 100; # Number of replications

Keybase proof

I hereby claim:

  • I am gvdr on github.
  • I am gvdr (https://keybase.io/gvdr) on keybase.
  • I have a public key ASBW8zEL_gVtBeSjRwk9_S8_4Xi1x1vlzFwdUc0JDHZDSwo

To claim this, I am signing this object:

@gvdr
gvdr / Birth_Canal_Diversity.md
Last active October 25, 2018 07:22
A quick exploratory analysis of the dataset collected by BEtti and Manica (Betti L, Manica A (2018) Human variation in the shape of the birth canal is significant and geographically structured. Proceedings of the Royal Society B 285(1889)

Diversity in Birth Canal across the world

A quick exploratory analysis of the dataset collected by BEtti and Manica (Betti L, Manica A (2018) Human variation in the shape of the birth canal is significant and geographically structured. Proceedings of the Royal Society B 285(1889): 20181807.)

We perform classic multidimensional scaling and contrast it with the aggregate means by Region and Population.

Let's load the tidyverse framework to wrangle data and plot it

@gvdr
gvdr / install_notes.txt
Created July 18, 2018 23:15
installation notes for DATA201 and DATA422
Data Wrangling Stack
--------------------
In this course we will use:
- R as default programming language
- Tidyverse as the R dialect of choice
- The shell commands (bash or zsh), through the terminal