This vignette defines every column of every dataset shipped with metrosp. The Metro Demand Data article covers the same datasets at length, with coverage windows by line, known source defects, and the conventions behind the numbers.
The package ships four demand datasets. Two measure passengers at the line level, and two at the station level.
| Dataset | Description | Unit | Time span | Frequency |
|---|---|---|---|---|
line_entries_monthly |
Passenger entries, measured at the station turnstiles, aggregated by day-type metrics. | Passengers | 2012–2026 | Monthly |
line_transported_monthly |
Passengers transported, measured at the turnstiles plus transfers between lines at interchange stations. | Passengers | 2012–2026 | Monthly |
station_transported_monthly |
Average business day passengers transported per station, aggregated by month. | Passengers | 2012–2026 | Monthly |
station_entries_daily |
Daily passenger entries at each station. | Passengers | 2012–2026 | Daily |
A passenger entry (entrada de passageiros) is a passenger who crossed the station’s turnstile gates (linha de bloqueios). A transported passenger (passageiro transportado) is one who boarded a train on that line, whether through a turnstile or by transferring from another line at an interchange station, so transported counts are always equal to or greater than entry counts.
All four datasets count individual passengers. line_transported_monthly covers Line 4 from 2012 and Line 5 only through August 2018; station_transported_monthly covers Line 5 only through July 2018.
Four further datasets support analysis. rail_lines and rail_stations carry route and station geometries; calendar_spo and metro_colors are lookup tables.
The bundled datasets are a fixed snapshot, current through July 2026. The snapshot moves when the column schema changes or when a release deliberately carries new data, never because new months were published upstream, so results computed from a given package version stay reproducible.
read_metro_demand() reads the most recently published data instead, from the rolling data-latest GitHub release the pipeline writes on every run.
library(metrosp)
# Latest published data
entrance <- read_metro_demand("line_entries_monthly")
# The month's published batch
entrance_sep <- read_metro_demand("line_entries_monthly", vintage = "2026-09")Columns are identical across sources, so everything below applies to both the bundled snapshot and the published data.
Three producers stand behind these datasets.
| Dataset | Granularity | Producer | Line coverage |
|---|---|---|---|
line_entries_monthly |
line × month × metric | METRO + Dataverse | All |
line_transported_monthly |
line × month × metric | METRO + Dataverse | Lines 1, 2, 3, 4, 5, and 15 |
station_transported_monthly |
station × month | METRO + Dataverse | Lines 1, 2, 3, 4, 5 (to Jul 2018), and 15 |
station_entries_daily |
station × day | METRO + Dataverse | All |
rail_lines |
line (spatial) | GeoSampa | All |
rail_stations |
station (spatial) | GeoSampa | All |
METRO SP transparency portal. The Companhia do Metropolitano de São Paulo publishes monthly demand reports at its transparency portal, covering Lines 1, 2, 3, 15, and Line 5 through July 2018. Values are reported in thousands.
Insper Dataverse. Line 4 (ViaQuatro) and Line 5 from August 2018 (ViaMobilidade) come from the Insper Dataverse, starting January 2012 and August 2018 respectively. Counts are not rounded to the nearest thousand, so the pipeline multiplies METRO values by 1,000 before combining the two.
GeoSampa. Line and station geometries come from GeoSampa, the City of São Paulo’s open geospatial platform. Both currently operating and planned infrastructure are included.
Station identity. station_id identifies a physical station complex, while station_name retains the official name used by each station member. Complex membership is maintained in a committed crosswalk from official network sources; it is not inferred from name similarity or distance. Thus Consolação and Paulista retain different names but share one station_id.
The term producer is deliberate. Combining these sources takes substantial cleaning, and the pipeline that does it lives in the package’s GitHub repository.
line_entries_monthlyMonthly passenger entries by metro line and day-type metric, in individual passengers.
| Column | Type | Description |
|---|---|---|
date |
Date | First day of the month |
year |
integer | Calendar year |
line_number |
integer | Line identifier (1, 2, 3, 4, 5, or 15) |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
metric |
character | Metric code: total, mdu, msa, mdo, max |
metric_name |
character | Metric label in English |
metric_name_pt |
character | Metric label in Portuguese |
value |
numeric | Passenger count |
The total, mdu, msa, and mdo metrics cannot be summed into a clean network total across operators: METRO line entries include transfers arriving from Lines 4 and 5, while Lines 4 and 5 count turnstiles only. The max metric cannot be summed either: individual lines may peak on different days.
METRO breaks each month into five metrics, shared by line_entries_monthly and line_transported_monthly.
| Code | English | Portuguese |
|---|---|---|
total |
Total passengers in the month | Total |
mdu |
Average on business days | Média dos Dias Úteis |
msa |
Average on Saturdays | Média dos Sábados |
mdo |
Average on Sundays | Média dos Domingos |
max |
Daily peak | Máxima Diária |
line_transported_monthlyMonthly passengers transported by metro line and day-type metric.
| Column | Type | Description |
|---|---|---|
date |
Date | First day of the month |
year |
integer | Calendar year |
line_number |
integer | Line identifier (1, 2, 3, 4, 5, or 15) |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
metric |
character | Metric code: total, mdu, msa, mdo, max |
metric_name |
character | Metric label in English |
metric_name_pt |
character | Metric label in Portuguese |
value |
numeric | Passengers transported |
Transported counts cannot be summed into a unique network count: a journey using multiple lines is counted once on each line.
station_transported_monthlyMonthly average weekday passengers transported per station. Only the weekday average is available at the station level; line_transported_monthly carries all five metrics at the line level. Grouping by station_id gives boardings across a complex’s platforms, not people entering it. Line 5 covers January 2016–July 2018 only.
| Column | Type | Description |
|---|---|---|
date |
Date | First day of the month |
year |
integer | Calendar year |
line_number |
integer | Line identifier |
station_id |
character | Stable, opaque physical-station identifier |
station_name |
character | Full station name |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
metric |
character | Metric code, always mdu |
metric_name |
character | Metric label in English |
metric_name_pt |
character | Metric label in Portuguese |
value |
numeric | Average weekday (business day) transported passengers |
station_entries_dailyDaily passenger entries at each station: turnstile entries plus transfers arriving from other operators, excluding transfers between METRO lines. Monthly station sums usually match the line’s total in line_entries_monthly; when they differ, the gap is a fraction of a percent.
| Column | Type | Description |
|---|---|---|
date |
Date | Date of observation |
year |
integer | Calendar year |
line_number |
integer | Line identifier |
station_id |
character | Stable, opaque physical-station identifier |
station_name |
character | Full station name |
station_code |
character | Three-letter METRO abbreviation (NA for Lines 4–5) |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
value |
numeric | Daily passenger entries |
rail_lines and rail_stations are sf objects in WGS 84 (EPSG:4326). Both cover METRO SP and CPTM commuter rail, operating and planned.
rail_lines| Column | Type | Description |
|---|---|---|
line_number |
integer | Official line number |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
company_name |
character | Operator (Metrô, ViaQuatro, ViaMobilidade, CPTM) |
type |
character | "metro" (underground) or "train" (CPTM commuter rail) |
status |
character | "current" (operating) or "future" (planned) |
geom |
LINESTRING | Route geometry |
rail_stations| Column | Type | Description |
|---|---|---|
station_id |
character | Stable, opaque physical-station identifier |
station_name |
character | Station name (title case) |
station_code |
character | Three-letter METRO abbreviation when available |
line_number |
integer | Line number |
line_name |
character | Line color in English |
line_name_pt |
character | Line color in Portuguese |
company_name |
character | Operator |
type |
character | "metro" or "train" |
status |
character | "current" or "future" |
geom |
POINT | Station location |
Transfer stations such as Sé, Paraíso, and Ana Rosa appear once per line they serve.
calendar_spoDaily calendar for the city of São Paulo, 2012–2030, flagging national, state, and municipal holidays. Join on date to build business-day aggregates from station_entries_daily.
| Column | Type | Description |
|---|---|---|
date |
Date | Calendar date |
year |
integer | Calendar year |
weekday |
integer | Day of week, 1 = Sunday through 7 = Saturday |
is_weekend |
logical | TRUE for Saturdays and Sundays |
is_holiday |
logical | TRUE when the date is a gazetted holiday |
is_business_day |
logical | TRUE when the date is neither a weekend nor a holiday |
holiday_name |
character | Holiday name in Portuguese, NA otherwise |
holiday_scope |
character | "national", "state", or "municipal" |
is_optional_holiday |
logical | TRUE for optional holidays, such as Carnaval Monday |
is_long_weekend |
logical | TRUE when a holiday falls on a Monday, Tuesday, Thursday, or Friday |
metro_colorsNamed character vector of the official hex colors for the six lines with ridership data. Names are the English line colors, so metro_colors["Blue"] returns "#171796". It pairs directly with ggplot2::scale_color_manual().
| Name | Hex |
|---|---|
Blue |
#171796 |
Green |
#007A5E |
Red |
#ED2E38 |
Yellow |
#FFD525 |
Lilac |
#874ABF |
Silver |
#8F8F8C |
These datasets are heavily processed and curated, so cite the package alongside the original producers. Run citation("metrosp") for the entry.