This project processes internal staffing data, filters specific operational roles, computes key metrics, restructures the table into long and wide formats, and exports the results into Excel. The final script also merges all generated Excel files into one consolidated workbook.
The code is modular and follows a clear linear pipeline:
- Filtering and cleaning
- Normalization and numeric conversion
- Metric calculations
- Long-format transformation
- Aggregation and reshaping
- Excel export
- Automatic merging of all output files
- Load raw staffing dataset (
SHBN.csv). - Rename important columns (e.g.,
Площадка/ Дивизион→place). - Filter only:
- rows whose position contains "ороситель"
- rows belonging to 01 Операционная деятельность
- Convert key columns to numeric.
- Replace missing optimization values with
0.
The script computes:
- В подчинении всего =
В подчинении на одного×Численность сейчас - Целевая численность =
Численность сейчас−Целевая оптимизация
These KPIs are later used for long-format restructuring.
The table is transformed into a long structure via pivot_longer(),
with:
Показатель— type of metricЗначение— numeric value
Then grouped and summarised by:
- place
- position (
Должность) - indicator (
Показатель)
The cleaned long table is expanded back into a wide format:
Показательbecomes the row index- Each
placebecomes a separate column - Missing values filled with
0
The result is written to an Excel file.
All generated .xlsx files inside the output folder are:
- loaded
- inserted into a single multi-sheet workbook
- saved as
merged.xlsx
This creates one consolidated file for review or management reporting.
readxl openxlsx writexl dplyr tidyr stringr ggplot2 lubridate tidyverse
Results and samples are not provided due to company restrictions :)