Skip to contents

Single R-side dispatcher for the rmorie command line's rmorie analyze <subject> verb. The CLI shells out with Rscript -e 'rmorie::cli_main("<subject>", "<json>")' and forwards the parsed command-line flags as one JSON object; this function loads the subject's data, runs the corresponding analysis suite, and prints the result to stdout as JSON. It is not intended for interactive use.

Usage

cli_main(subject, json = "{}")

Arguments

subject

Character scalar naming the analysis subject.

json

Character scalar: a JSON object of options forwarded from the CLI flags (default "\\\\\\\\{\\\\\\\\}"). Unknown keys are ignored.

Value

Invisibly, the analysis result (a list). As a side effect, prints that result to stdout as JSON.

Details

Supported subjects:

The "tps" subject runs morie_tps_analyze_all on the datasets named in {"datasets": [...], "nrows": N} (as morie_tps_load takes them) or read from {"data": FILE}; without either it returns an error status (exit code 1 from the CLI).

Examples

# \donttest{
cli_main("otis", "{}")
#> analyze otis: a 5-row SYNTHETIC sample shaped like the data.ontario.ca A01 table (it demonstrates the pipeline; its numbers are not findings); the real table: rmorie pull otisa01 --out FILE, then '{"data":"FILE"}'
#> {"rplace":{"title":"OTIS regional placement -- FY 2024","summary_lines":{"Year":2024,"Sex filter":"all","Age groups":"50 to 64","Regions":"Central, Eastern, Northern, Toronto, Western","Total individuals":1},"tables":[{"title":"Counts (age x region):","headers":["age","Central","Eastern","Northern","Toronto","Western"],"rows":[["50 to 64","0","0","1","0","0"]]},{"title":"Proportions (within age):","headers":["age","Central","Eastern","Northern","Toronto","Western"],"rows":[["50 to 64","0.0%","0.0%","100.0%","0.0%","0.0%"]]}],"interpretation":"","warnings":"OTIS UniqueIndividual_ID is year-locked; counts are within-FY only.","payload":{"counts":[[0,0,1,0,0]],"props":[[0,0,1,0,0]],"year":2024,"sex":null}},"astcmb":{"title":"OTIS alert-state combination encoding","summary_lines":{"Person-year cells":5,"Distinct complexity levels":1},"tables":[{"title":"Count by alert-complexity level:","headers":["ac","n_persons"],"rows":[[1,5]]}],"interpretation":"Each (person, fiscal-year) cell is encoded as one of 8 alert combinations of (mental_health, suicide_risk, suicide_watch). a8 = no alerts; a7 = all three. The complexity index `ac` counts how many distinct combinations the person-year occupied. Higher ac = more concurrent risk-flag patterns within the FY.","warnings":"OTIS UniqueIndividual_ID is year-locked; ac is within-FY.","payload":{"per_person_year":[{"id":"2022-SYNTH-001-RC","yr":2022,"a1":1,"a2":0,"a3":0,"a4":0,"a5":0,"a6":0,"a7":0,"a8":0,"ac":1},{"id":"2022-SYNTH-002-RC","yr":2022,"a1":0,"a2":0,"a3":0,"a4":0,"a5":0,"a6":0,"a7":0,"a8":1,"ac":1},{"id":"2023-SYNTH-003-RC","yr":2023,"a1":0,"a2":0,"a3":0,"a4":1,"a5":0,"a6":0,"a7":0,"a8":0,"ac":1},{"id":"2023-SYNTH-004-RC","yr":2023,"a1":0,"a2":0,"a3":0,"a4":0,"a5":0,"a6":0,"a7":0,"a8":1,"ac":1},{"id":"2024-SYNTH-005-RC","yr":2024,"a1":0,"a2":0,"a3":0,"a4":0,"a5":0,"a6":1,"a7":0,"a8":0,"ac":1}],"summary":[{"ac":1,"n_persons":5}]}},"volat":{"title":"OTIS regional volatility (placement movement)","summary_lines":{"Person-year cells":5,"Mean volatility":1,"Median volatility":1,"Min":1,"Max":1},"tables":[],"interpretation":"Volatility = number of distinct regions a person-year passed through, taking the union of `region_at_time_of_placement` and `region_most_recent_placement`. Higher = more movement. Strictly within-FY -- cross-year mobility is not measurable because OTIS IDs are year-locked.","warnings":"Intra-FY only (OTIS IDs are year-locked).","payload":{"per_person_year":[{"cell":"2022-SYNTH-001-RC\u001f2022","vm":1},{"cell":"2022-SYNTH-002-RC\u001f2022","vm":1},{"cell":"2023-SYNTH-003-RC\u001f2023","vm":1},{"cell":"2023-SYNTH-004-RC\u001f2023","vm":1},{"cell":"2024-SYNTH-005-RC\u001f2024","vm":1}],"mean":1,"median":1}},"rctrnd":{"title":"OTIS restrictive-confinement trends over time","summary_lines":{"Years observed":"2022-2024","Rows":5},"tables":[{"title":"Restrictive-confinement counts by year x region:","headers":["year","region","n_individuals","n_placements"],"rows":[{"year":2022,"region":"Eastern","n_individuals":1,"n_placements":1},{"year":2022,"region":"Toronto","n_individuals":1,"n_placements":1},{"year":2023,"region":"Central","n_individuals":1,"n_placements":1},{"year":2023,"region":"Western","n_individuals":1,"n_placements":1},{"year":2024,"region":"Northern","n_individuals":1,"n_placements":1}]}],"interpretation":"","warnings":"Per-year aggregates (OTIS IDs are year-locked).","payload":{"trends":[{"year":2022,"region":"Eastern","n_individuals":1,"n_placements":1},{"year":2022,"region":"Toronto","n_individuals":1,"n_placements":1},{"year":2023,"region":"Central","n_individuals":1,"n_placements":1},{"year":2023,"region":"Western","n_individuals":1,"n_placements":1},{"year":2024,"region":"Northern","n_individuals":1,"n_placements":1}]}},"otdesc":{"title":"OTIS descriptives","summary_lines":{"Total individuals (unique)":5,"Total records":5,"Mean placements/person":1,"Median placements/person":1,"Max placements/person":1,"Tables emitted":4},"tables":[{"title":"n_by_year:","headers":["end_fiscal_year","n"],"rows":[{"end_fiscal_year":2022,"n":2},{"end_fiscal_year":2023,"n":2},{"end_fiscal_year":2024,"n":1}]},{"title":"n_by_region:","headers":["region_at_time_of_placement","n"],"rows":[{"region_at_time_of_placement":"Central","n":1},{"region_at_time_of_placement":"Eastern","n":1},{"region_at_time_of_placement":"Northern","n":1},{"region_at_time_of_placement":"Toronto","n":1},{"region_at_time_of_placement":"Western","n":1}]},{"title":"n_by_age:","headers":["age_category","n"],"rows":[{"age_category":"18 to 24","n":1},{"age_category":"25 to 49","n":2},{"age_category":"50 to 64","n":2}]},{"title":"n_by_gender:","headers":["gender","n"],"rows":[{"gender":"Female","n":2},{"gender":"Male","n":3}]}],"interpretation":"","warnings":[],"payload":{"n_total":5,"n_records":5,"placement_dist":{"min":1,"q1":1,"median":1,"mean":1,"q3":1,"max":1}}}}
# }