inout_tables_final: Adjusts seizures and weights out given multiple countries of...

Description Usage Arguments Details Value See Also Examples

View source: R/inout_tables_final.R

Description

Computes corrected number of seizures and weights in and out after adjusting for multiple countries of origin. Outputs can be saved as a csv file, or into the database or as an Excel Workbook.

Usage

1
2
3
inout_tables_final(year.from = 1900, year.to = 2100, statusMin = 3,
  ctry_dest_included, size.min = 0, which.out = 1:3, mult.data,
  inout.data, double.recs)

Arguments

year.from

Starting year

year.to

Ending year

statusMin

Minimum status of seizure record to include in summary (usually 3)

ctry_dest_included

true if ctry of dest included in computing szs out TRUE for trade flows and FALSE for LE ratio accounting. If this is different to the options for df.inout then the function aborts

size.min

This is by default set to zero but is useful when wanting list of seizures used in cluster analysis when a size cutoff is used

which.out

which outputs to include. Denotes which of the outputs to be produced. If it includes 2 then year.from = 1900, year.to = 2100 and size.min = 0.

double.recs

List created using double_count of seizures in which countries of raw and worked origin are not (all) the same

mult

List created using mult_ctries() with countries of discovery, transit and destination for seizures with multiple countries of origin

df.inout

List created using inout_tables_LE_TF_prep with list of seizures and weights in and out uncorrected for multiple countries of origin

Details

The output from this function is a list of seizures and weights in and out. The user can choose which outputs are required.

This function interacts with the ETIS database and the list of relevant seizures stored in df.1 from df_quantities_RIE_separate.fn.

The main use of this function is to contribute to the calculation of two new database tables for law enforcement ratio and trade flow accounting.

This function makes an adjustment for seizure 109462. For this seizure there is a country of transit listed that falls after the country of discovery. For that country, the seizure needs to be included in trade flow but not LE ratio accounting.

Value

This writes files to three different places. Each gives seizures and weights in and out for each country and year specified:

  1. csv file: NAME.csv

  2. database table: szwt_NAME - requires size.min = 0, year.from = 1900, year.to = 2100

  3. Excel workbook: NAME.xlsx with separate sheets for: sz in, sz out, wt in, wt out, sz flow, wt flow

The file names depend on the accounting method that is required and the years included. So file name might be LE_1900_2100.csv or TF_1900_2100.csv. The start of the file name relates to:

LE for LE ratio accounting - the country of destination excluded
TF if for trade flow accounting - the country of destination included

The years are set as this large range when writing to the database#

See Also

df_quantities_RIE_separate, mult_ctries, inout_tables_prep double_count

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
year.from <- 1900
year.to <- 2100
statusMin <- 3
which.out <- 1:3

df.1 <- df_quantities_RIE_separate(year.from = year.from, year.to = year.to,
statusMin = statusMin, reg.model = 'wt est.Rdata')

mult.dat <- mult_ctries(year.from = year.from, year.to = year.to, statusMin = statusMin, df.1 = df.1)

double.recs <- double_count(year.from = year.from, year.to = year.to, statusMin = statusMin, df.RIE = df.1)

ctry_dest_included <- FALSE

df.inout <- inout_tables_prep(year.from = year.from,year.to = year.to,
statusMin = statusMin,ctry_dest_included = ctry_dest_included, df.1 = df.1)

inout_tables_final(year.from = year.from, year.to = year.to,
statusMin = statusMin, ctry_dest_included = ctry_dest_included,
size.min = size.min, which.out = which.out, mult.data = mult.dat,
inout.data = df.inout, double.recs = double.recs )

fmunderwood/ETISdbase documentation built on Feb. 29, 2020, 12:46 a.m.