# To build this vignette run 
devtools::build_vignettes()
# Then rebuild the package CTRL+SHIFT+B so that the vignette is 
# integrated to the package documentation

Function documentation can be accessed at the R command line by entering a question mark "?" followed by a function name. For example enter ?clean at the command prompt to see the documentation for that function.

Refining trade flows data from a database

There are functions to clean (estimate missing quantities) trade flow data and write this cleaned data into the database.

The methodology report explains the data refining process in details. The source code of the clean() fonction gives details on the implementation of the data refining workflow.

library(tradeflows)
?clean # View help for this function

# Here are the steps performed when cleaning data from the database 
# (more convenient function further below)
# Read a data frame from the database
sawnwood99_raw <- readdbproduct(440799, "raw_flow_yearly")
# Clean the data frame
sawnwood99_validated <- clean(sawnwood99_raw)
# Select columns to write to the database
columnswrite <- tradeflows::column_names$efi[column_names[,"validated_flow_yearly"]]
columnswrite <- columnswrite[!columnswrite == "lastchanged"]
sawnwood99_validated <- sawnwood99_validated %>% select_(.dots = columnswrite)
# Delete product from the validated table 
deletedbproduct(440799, "validated_flow_yearly")
# Write the data frame to the database
writedbproduct(sawnwood99_validated, "validated_flow_yearly")

# Those functions together in one go
cleandbproduct(440799, "raw_flow_yearly", "validated_flow_yearly")

Notes on partner flow

The parter flow in the database is the one before the modification.



EuropeanForestInstitute/tradeflows documentation built on Oct. 7, 2019, 10:57 a.m.