convert.tfr.trajectories {bayesTFR}R Documentation

Converting TFR Trajectories into ACSII Files


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


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



Directory containing the prediction object. It should correspond to the output.dir argument of the tfr.predict function.


Number of trajectories to be stored. It can be either a single number or the word “all” in which case all trajectories are stored.


Directory in which the resulting files will be stored. If NULL the same directory is used as for the prediction.


Logical switching log messages on and off.


The function creates two files. One is called “ascii_trajectories.csv”, it is a comma-separated table with the following columns:

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.


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.


Hana Sevcikova

See Also

write.projection.summary, tfr.predict


## 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,, 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]