convert.e0.trajectories {bayesLife} | R Documentation |
Converting Trajectories of Life Expectancy into ACSII Files
Description
Converts trajectories of the life expectancy stored in a binary format into two CSV files of a UN-specific format.
Usage
convert.e0.trajectories(dir = file.path(getwd(), "bayesLife.output"),
n = 1000, output.dir = NULL, verbose = FALSE)
Arguments
dir |
Directory containing the prediction object. It should correspond to the |
n |
Number of trajectories to be stored. It can be either a single number or the word “all” in which case all available trajectories are converted. |
output.dir |
Directory in which the resulting files will be stored. If |
verbose |
Logical switching log messages on and off. |
Details
The function creates two files per sex. One is called “ascii_trajectories.csv”, it is a comma-separated table with the following columns:
“LocID”: country code
“Period”: prediction interval, e.g. 2015-2020
“Year”: middle year of the prediction interval
“Trajectory”: identifier of the trajectory
“e0”: life expectancy
The second file is called “ascii_trajectories_wide.csv”, it is also a comma-separated table and it contains the same information as above but in a ‘transposed’ format. I.e. the data for one country are ordered in columns, thus, there is one column per country. The country columns are ordered alphabetically.
If n
is smaller than the total number of trajectories, the trajectories are selected using equal spacing.
Note
This function is automatically called from the e0.predict
function, therefore in standard cases it will not be needed to call it directly. However, it can be useful for example, if different number of trajectories are to be converted, without having to re-run the prediction.
Author(s)
Hana Sevcikova
See Also
write.e0.projection.summary
, e0.predict
Examples
## Not run:
sim.dir <- file.path(find.package("bayesLife"), "ex-data", "bayesLife.output")
pred.dir <- file.path(getwd(), "exampleLEpred")
# stores 10 trajectories out of 30 (60-30) into
# exampleLEpred/predictions/ascii_trajectories.csv (for female)
# and exampleLEpred/predictions/joint_male/ascii_trajectories.csv (for male)
e0.predict(sim.dir = sim.dir, output.dir = pred.dir,
burnin = 30, save.as.ascii = 10, verbose = TRUE)
# stores all 30 trajectories into the current directory
convert.e0.trajectories(dir = pred.dir, n = "all", output.dir = ".", verbose = TRUE)
# Note: If the output.dir argument in e0.predict is omitted,
# call convert.e0.trajectories with dir = sim.dir
## End(Not run)