Converts trajectories of the life expectancy stored in a binary format into two CSV files of a UN-specific format.
Directory containing the prediction object. It should correspond to the
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.
Directory in which the resulting files will be stored. If
Logical switching log messages on and off.
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.
n is smaller than the total number of trajectories, the trajectories are selected using equal spacing.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.