Run The End-To-End Projection Workflow
Usage
fast.proj_pop(
infile,
inparm_lt,
inparm_scene,
inparm_scene_k = 3,
move = FALSE,
initial_year = 2020,
project_year = NULL,
area_name = "某省",
pop_name = "常住人口",
path_excel = NULL,
path_pic = NULL,
path_word = NULL,
font_pic = NULL,
font_word = NULL
)Arguments
- infile
Baseline population data frame returned by
read_pop().- inparm_lt
Life table parameter list returned by
mod_lx().- inparm_scene
Scenario parameter list returned by
read_param().- inparm_scene_k
Number of scenarios to use from
inparm_scene.- move
Logical; if
TRUE, include net migration from scenario parameter columnmove.- initial_year
Initial calendar year used in output tables and charts.
- project_year
Number of years to project. If
NULL, use the length frominparm_scene[[1]].- area_name
Area label used in report titles.
- pop_name
Population label used in report titles.
- path_excel
Directory to save Excel outputs. If
NULL, defaults to~/Desktop/fastproj_output/excel.- path_pic
Directory to save PNG figures. If
NULL, defaults to~/Desktop/fastproj_output/pic.- path_word
Directory to save Word report. If
NULL, defaults to~/Desktop/fastproj_output/word.- font_pic
Font family for plots. If
NULL, use a platform-adapted Chinese font.- font_word
Font family for Word tables. If
NULL, use a platform-adapted Chinese font.
Value
A named list with:
excel_dirDirectory containing projected population structure and summary Excel files.
pic_dirDirectory containing generated PNG charts.
wordPath to the generated Word report (
projection_outcome.docx).
Details
fast.proj_pop() is the high-level one-click interface for beginners.
It combines mortality projection, fertility projection, cohort-component
population projection, and report export into one function call.
Typical workflow:
Read baseline data with
read_pop().Read scenario parameters with
read_param().Build life-table parameters with
mod_lx().Run
fast.proj_pop()once to export Excel + PNG + Word outputs.
Examples
# \donttest{
data("infile_pop", package = "fastproj")
data("inparm_scene", package = "fastproj")
if (!requireNamespace("DemoTools", quietly = TRUE)) {
message("Install DemoTools with: remotes::install_github('timriffe/DemoTools')")
} else {
inparm_lt <- mod_lx(
q0_5_m = 0.00318, e0_m = 76.75,
q0_5_f = 0.00264, e0_f = 82.22
)
dir_excel <- file.path(path.expand("~"), "Desktop", "fastproj_output", "excel")
dir_pic <- file.path(path.expand("~"), "Desktop", "fastproj_output", "pic")
dir_word <- file.path(path.expand("~"), "Desktop", "fastproj_output", "word")
out <- fast.proj_pop(
infile = infile_pop,
inparm_lt = inparm_lt,
inparm_scene = inparm_scene,
move = TRUE,
path_excel = dir_excel,
path_pic = dir_pic,
path_word = dir_word
)
out$word
}
#> [1] "/Users/yuteng/Desktop/fastproj_output/word/projection_outcome.docx"
# }