Sync portfolio laboratory source

This commit is contained in:
portfolio 2026-11-26 13:13:26 +03:00
commit 648547a954
5 changed files with 84 additions and 0 deletions

13
analysis.R Normal file
View file

@ -0,0 +1,13 @@
# Синтетические данные и расчёт метрик для обоих дашбордов.
set.seed(2026)
group <- rep(c("A", "B", "C"), each = 50)
income <- rlnorm(length(group), rep(c(10, 10.3, 10.6), each = 50), 0.5)
result <- aggregate(cbind(median = income, log_median = log(income)), list(group = group), median)
# Проверяет конечность основной метрики перед экспортом.
stopifnot(nrow(result) > 1, all(is.finite(result$median)))
if (sys.nframe() == 0L) {
arguments <- commandArgs(trailingOnly = TRUE)
stopifnot(length(arguments) == 1L)
write.csv(result, arguments[1], row.names = FALSE)
}