convert.tfr.trajectories {bayesTFR} R Documentation

## Converting TFR Trajectories into ACSII Files

### Description

Converts TFR trajectories stored in a binary format into two CSV files of a UN-specific format.

### Usage

convert.tfr.trajectories(dir = file.path(getwd(), 'bayesTFR.output'),
n = 1000, output.dir = NULL, verbose = FALSE)


### Arguments

 dir Directory containing the prediction object. It should correspond to the output.dir argument of the tfr.predict function. n Number of trajectories to be stored. It can be either a single number or the word “all” in which case all trajectories are stored. output.dir Directory in which the resulting files will be stored. If NULL the same directory is used as for the prediction. verbose Logical switching log messages on and off.

### Details

The function creates two files. 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

• “TF”total fertility rate

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 tfr.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

write.projection.summary, tfr.predict

### Examples

## Not run:
sim.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
pred.dir <- file.path(getwd(), "exampleTFRpred")

# stores 10 trajectories out of 35 (1x(60-25)) into
# exampleTFRpred/predictions/ascii_trajectories.csv
tfr.predict(sim.dir=sim.dir, output.dir=pred.dir, use.tfr3=FALSE,
burnin=25, save.as.ascii=10, verbose=TRUE)

# stores all 35 trajectories into the current directory
convert.tfr.trajectories(dir=pred.dir, n="all", output.dir=".", verbose=TRUE)

# Note: If the output.dir argument in tfr.predict is omitted,
# call convert.tfr.trajectories with dir=sim.dir

## End(Not run)


[Package bayesTFR version 7.2-0 Index]