Skip to content

Instantly share code, notes, and snippets.

View florisvdh's full-sized avatar

Floris Vanderhaeghe florisvdh

View GitHub Profile
@florisvdh
florisvdh / summarize.md
Created January 5, 2025 16:31
Combining multiple summaries in summarize(): beware
library(dplyr, warn.conflicts = FALSE)

glimpse(faithful)
#> Rows: 272
#> Columns: 2
#> $ eruptions <dbl> 3.600, 1.800, 3.333, 2.283, 4.533, 2.883, 4.700, 3.600, 1.95…
#> $ waiting   <dbl> 79, 54, 74, 62, 85, 55, 88, 85, 51, 85, 54, 84, 78, 47, 83, …

# Using a single summary function in summarize(), not adding across().
@florisvdh
florisvdh / RMI_SYNOP_WFS.md
Last active September 27, 2023 12:36
Downloading meteorological RMI data from the WFS service RMI_SYNOP_WFS
@florisvdh
florisvdh / qgisprocess_project_path_reprex.md
Created September 1, 2022 07:31
Reprex qgisprocess::qgis_run_algorithm(PROJECT_PATH=)
library(qgisprocess)
#> Using 'qgis_process' in the system PATH.
#> QGIS version: 3.26.2-Buenos Aires
#> Configuration loaded from '~/.cache/R-qgisprocess/cache-0.0.0.9000.rds'
#> Run `qgis_configure(use_cached_data = TRUE)` to reload cache and get more details.
#> >>> If you need another installed QGIS version, run `qgis_configure()`;
#>     see its documentation if you need to preset the path of qgis_process.
#> - Using JSON for input serialization.
#> - Using JSON for output serialization.
@florisvdh
florisvdh / examples_total_variance.md
Last active July 28, 2021 08:25
Does the order of aggregating have an effect on the total variance? It depends.

When aggregating groups of observations, depending on the objective, one usually wants to represent both the within-group and the between-group uncertainty, resulting in the total variance of the target variable (ind in below examples).

In applying the referred formula for the specific case of equal-sized groups, it can be asked whether the group indices j and the group-member indices i can be switched, i.e. considering i = 1 as group 1, i = 2 as group 2 etc., hence flipping the order of aggregating.

In the first revision of this gist it was concluded that this was the case, i.e. that indices can be flipped. However the example had quite stringent conditions, such as (A) max(i) = max(j) and (B) a fixed within-group variance. From below experiments, it can be seen that index flipping can still be done when either A or B or relaxed. However when both are relaxed, it is no longer true. In that case the difference between both total variances