Publications by Michael

Bibliography with knitr : cite your references and packages

02.02.2019

A tutorial to use your Zotero references with rmarkdown, easily add the references, automatically generate your bibliography, including the packages used in your document. It’s a good practice to cite the R packages you use in your analysis. However it can be cumbersome to maintain the list of your package’s references in Zotero while the pa...

2327 sym R (2086 sym/1 pcs) 8 img

Mapping multiple trends with confidence

06.02.2019

A tutorial to compute trends by groups and plot/map the results We will use dplyr::nest to create a list-column and will apply a model (with purrr::map) to each row, then we will extract each slope and its p-value with map and broom::tidy. Setup library(tidyverse) library(httr) library(sf) library(readxl) library(janitor) library(fs) library(broo...

932 sym R (4101 sym/6 pcs) 4 img

Generate multiple language version plots

13.02.2019

The use case is to create the same plot in different languages. I used this technique for Wikipedia plots. We are going to build a list containing all translations, we will then loop over each language, generating and saving the plot. # Mauna Loa atmospheric CO2 change # multi language plot for Wikipedia # Required packages library(tidyverse) li...

661 sym R (6112 sym/1 pcs) 12 img

Post to Mastodon from R

15.02.2019

Mastodon is a decentralized microblogging platform. We can analyse some data and directly post our findings to a Mastodon instance. For example we can plot the different TLDs used by the Mastodon Fediverse. library(tidyverse) library(httr) library(jsonlite) library(scales) library(ggthemes) library(ggrepel) # data source url <- "https://instance...

739 sym R (3825 sym/4 pcs) 4 img

Open and merge multiple shapefiles

27.03.2019

or more precisely union many spatial tables in R in a tidy way. dplyr::bind_rows doesn’t work on sf objects ; base::rbind only work on two tables and so that’s not straightforward to use*. So we’ll use purrr::map and tidyr::unnest. First get some data, the communes of three french départements : library(tidyverse) library(sf) library(fs) l...

1013 sym R (863 sym/3 pcs) 2 img

Metadata : from PostgreSQL comments to R labels

18.04.2019

Metadata are an essential part of a robust data science workflow ; they record the meaning of each variable : its units, quality, allowed range, how we collect it, when it’s been recorded etc. Data without metadata are practically worthless. Here we will show how to transfer the metadata from PostgreSQL to R. In PostgreSQL metadata can be stor...

1812 sym R (1795 sym/7 pcs)

Kernel spatial smoothing : transforming points pattern to continuous coverage

11.05.2019

Representing mass data (inhabitants, livestock,…) on a map in not always easy : choropleth maps are clearly a no-go, except if you normalize with area and then you stumble on the MAUP… A nice solution is smoothing, producing a raster. You even get freebies like (potential) statistical confidentiality, a better geographic synthesis and easy mu...

2918 sym R (3209 sym/3 pcs) 8 img

Mauna Loa CO₂ polar plot

01.01.2020

After a classic plot (see our former post) used on Wikipedia, we can explore another data visualization. The CO₂ concentration, one of the main cause of the climate warming, is following a seasonal cycle so it could be interesting (or ironic ?) to use a polar plot. Config and data We only keep two translations for brevity here… # Required pac...

1028 sym R (3220 sym/2 pcs) 2 img

Coronavirus : spatially smoothed decease in France

30.03.2020

# Carto décès COVID 19 France # avec lissage # sources ----------------------------------------------------------------- fichier_covid <- "donnees/covid.csv" url_donnees_covid <- "https://www.data.gouv.fr/fr/datasets/r/63352e38-d353-4b54-bfd1-f1b3ee1cabd7" fichier_pop <- "donnees/pop.xls" # https://www.insee.fr/fr/statistiques/2012713#tablea...

396 sym R (5195 sym/1 pcs) 2 img

COVID-19 decease animation map

01.04.2020

Coronavirus decease in France # Animation carto décès COVID 19 France # avec lissage # sources ----------------------------------------------------------------- # https://www.data.gouv.fr/fr/datasets/donnees-hospitalieres-relatives-a-lepidemie-de-covid-19/ fichier_covid <- "donnees/covid.csv" url_donnees_covid <- "https://www.data.gouv.fr/fr/...

425 sym R (7431 sym/1 pcs) 2 img