Learn R Programming

bayesTFR (version 4.2-0)

convert.tfr.trajectories: 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

Rdversion

1.1

dQuote

ascii_trajectories_wide.csv

sQuote

transposed

code

n

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}

See Also

write.projection.summary, tfr.predict

Examples

Run this code
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

Run the code above in your browser using DataLab