diff --git a/docs/articles/vignette_preparing_data.html b/docs/articles/vignette_preparing_data.html index f79c9dc3..1bf570c3 100644 --- a/docs/articles/vignette_preparing_data.html +++ b/docs/articles/vignette_preparing_data.html @@ -113,7 +113,7 @@
vignettes/vignette_preparing_data.Rmd
vignette_preparing_data.Rmd
Process_Raw_FAO_Data <- FALSE
in
-constants.R
. * The prebuilt data were generated using
-FAOSTAT data archived in Zenodo address specified in the
-FF_download_RemoteArchive
function (Zhao 2023).
+Data of the package.
+Process_Raw_FAO_Data <- FALSE
in
+constants.R
.FF_download_RemoteArchive
+function (Zhao 2023).Example:
-# Dataset PP, producer prices, is downloaded from RemoteArchiveURL to DATA_FOLDER
-# RemoteArchiveURL = "https://zenodo.org/record/8260225/files/"
-# DATA_FOLDER = "inst/extdata/aglu/FAO/FAOSTAT"
-FF_download_RemoteArchive(
- DATASETCODE = "PP",
- OverWrite = TRUE # overwrite existing PP dataset
- )
-
-# Dataset OA, population, is downloaded from FAOSTAT to DATA_FOLDER
-FF_download_FAOSTAT(DATASETCODE = "OA", OverWrite = TRUE)
-
-# Note that single DATASETCODE is allowed in both functions.
# Dataset PP, producer prices, is downloaded from RemoteArchiveURL to DATA_FOLDER
+# RemoteArchiveURL = "https://zenodo.org/record/8260225/files/"
+# DATA_FOLDER = "inst/extdata/aglu/FAO/FAOSTAT"
+FF_download_RemoteArchive(
+ DATASETCODE = "PP",
+ OverWrite = TRUE # overwrite existing PP dataset
+ )
+
+# Dataset OA, population, is downloaded from FAOSTAT to DATA_FOLDER
+FF_download_FAOSTAT(DATASETCODE = "OA", OverWrite = TRUE)
+
+# Note that single DATASETCODE is allowed in both functions.
Example:
-# Provide detailed metadata of "PP" and "OA" in DATA_FOLDER ("inst/extdata/aglu/FAO/FAOSTAT")
-FF_rawdata_info(DATASETCODE = c("PP", "OA"), DOWNLOAD_NONEXIST = FALSE)
-
-# If "PP" or "OA" does not exist, download from remote archive
-FF_rawdata_info(DATASETCODE = c("PP", "OA"), DOWNLOAD_NONEXIST = TRUE, FAOSTAT_or_Archive = "Archive")
# Provide detailed metadata of "PP" and "OA" in DATA_FOLDER ("inst/extdata/aglu/FAO/FAOSTAT")
+FF_rawdata_info(DATASETCODE = c("PP", "OA"), DOWNLOAD_NONEXIST = FALSE)
+
+# If "PP" or "OA" does not exist, download from remote archive
+FF_rawdata_info(DATASETCODE = c("PP", "OA"), DOWNLOAD_NONEXIST = TRUE, FAOSTAT_or_Archive = "Archive")
-# Read raw data of "PP" and "OA" from DATA_FOLDER ("inst/extdata/aglu/FAO/FAOSTAT") to .GlobalEnv
-FAOSTAT_load_raw_data(DATASETCODE = c("PP", "OA"), .Envir = .GlobalEnv)
# Read raw data of "PP" and "OA" from DATA_FOLDER ("inst/extdata/aglu/FAO/FAOSTAT") to .GlobalEnv
+FAOSTAT_load_raw_data(DATASETCODE = c("PP", "OA"), .Envir = .GlobalEnv)
vignettes/vignette_processing_flow.Rmd
vignette_processing_flow.Rmd
info
-* The function returns information of an object, including name,
-metadata information, precursors and dependents.
-dstrace
-* The function is able to trace data flows by providing precursors and
-dependents of an object recursively.
load_from_cache
-* If a drake cache is available, e.g., when driver_drake()
-had been run, this function, if given a list of object names, loads the
-objects from the cache into a list of data frames.
-* The function get_data_list
-can be used to assign each object in the list to a data frame.
driver_drake()
had been run, this function, if given a list
+of object names, loads the objects from the cache into a list of data
+frames.get_data_list
+can be used to assign each object in the list to a data frame.
-# Load gcamfaostat
-# devtools::load_all()
-library(gcamfaostat)
-# package data, GCAM_DATA_MAP, will be loaded
-
-# Get information for an intermediate data frame QCL_CROP_PRIMARY
-info("QCL_CROP_PRIMARY")
-#> QCL_CROP_PRIMARY - produced by module_xfaostat_L102_ProductionArea
-#> FAO primary crop area and production (various)
-#> Detailed FAO QCL data processing for crop area and production
-#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV
-#> Precursor: aglu/FAO/FAO_an_items_PRODSTAT
-#> Precursor: QCL_wide
-#> Precursor: FBS_wide
-#> Precursor: FBSH_CB_wide
-
-# Trace all downstream data flows for SCL_wide
-dstrace("SCL_wide", direction = "downstream", recurse = T)
-#> 1 - SCL_wide - produced by module_xfaostat_L101_RawDataPreProc3_SCL_FBS
-#> FAO supply utilization account dataset, 2010+, wide (tonne)
-#> Preprocessed FAOSTAT SCL; ** PRE-BUILT **
-#> Dependent: Bal_new_all (#2 below)
-#> Dependent: SUA_food_macronutrient_rate (#3 below)
-#> 2 - Bal_new_all - produced by module_xfaostat_L105_DataConnectionToSUA
-#> Bal_new_all (Ktonne)
-#> Preprocessed FAO SUA 2010 - 2019
-#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV (#4 below)
-#> 4 - xfaostat_L199_GCAMDATA_FAOSTAT_CSV - produced by module_xfaostat_L199_CSVExportAgSUA
-#> Export CSV to DIR_OUTPUT_CSV (NA)
-#> Export CSV
-#> No dependents
-#> 3 - SUA_food_macronutrient_rate - produced by module_xfaostat_L106_FoodMacroNutrient
-#> FAO food calories and macronutrient rate (rates)
-#> Detailed FAO food calories and macrotunitent info for 414 SUA items +
-#> 12 fish items
-#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV (#4 above)
-
-# Get input of a module
-inputs_of("module_xfaostat_L105_DataConnectionToSUA")
-#> [1] "aglu/FAO/FAO_items" "aglu/FAO/Mapping_FBSH_SCL_OilCake"
-#> [3] "QCL_PROD" "QCL_AN_LIVEANIMAL_MEATEQ"
-#> [5] "TCL_wide" "TM_bilateral_wide"
-#> [7] "FBSH_CB_wide" "FBS_wide"
-#> [9] "SCL_wide"
-
-# Get output of a module
-outputs_of("module_xfaostat_L106_FoodMacroNutrient")
-#> [1] "SUA_food_macronutrient_rate"
# Load gcamfaostat
+# devtools::load_all()
+library(gcamfaostat)
+# package data, GCAM_DATA_MAP, will be loaded
+
+# Get information for an intermediate data frame QCL_CROP_PRIMARY
+info("QCL_CROP_PRIMARY")
+#> QCL_CROP_PRIMARY - produced by module_xfaostat_L102_ProductionArea
+#> FAO primary crop area and production (various)
+#> Detailed FAO QCL data processing for crop area and production
+#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV
+#> Precursor: aglu/FAO/FAO_an_items_PRODSTAT
+#> Precursor: QCL_wide
+#> Precursor: FBS_wide
+#> Precursor: FBSH_CB_wide
+
+# Trace all downstream data flows for SCL_wide
+dstrace("SCL_wide", direction = "downstream", recurse = T)
+#> 1 - SCL_wide - produced by module_xfaostat_L101_RawDataPreProc3_SCL_FBS
+#> FAO supply utilization account dataset, 2010+, wide (tonne)
+#> Preprocessed FAOSTAT SCL; ** PRE-BUILT **
+#> Dependent: Bal_new_all (#2 below)
+#> Dependent: SUA_food_macronutrient_rate (#3 below)
+#> 2 - Bal_new_all - produced by module_xfaostat_L105_DataConnectionToSUA
+#> Bal_new_all (Ktonne)
+#> Preprocessed FAO SUA 2010 - 2019
+#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV (#4 below)
+#> 4 - xfaostat_L199_GCAMDATA_FAOSTAT_CSV - produced by module_xfaostat_L199_CSVExportAgSUA
+#> Export CSV to DIR_OUTPUT_CSV (NA)
+#> Export CSV
+#> No dependents
+#> 3 - SUA_food_macronutrient_rate - produced by module_xfaostat_L106_FoodMacroNutrient
+#> FAO food calories and macronutrient rate (rates)
+#> Detailed FAO food calories and macrotunitent info for 414 SUA items +
+#> 12 fish items
+#> Dependent: xfaostat_L199_GCAMDATA_FAOSTAT_CSV (#4 above)
+
+# Get input of a module
+inputs_of("module_xfaostat_L105_DataConnectionToSUA")
+#> [1] "aglu/FAO/FAO_items" "aglu/FAO/Mapping_FBSH_SCL_OilCake"
+#> [3] "QCL_PROD" "QCL_AN_LIVEANIMAL_MEATEQ"
+#> [5] "TCL_wide" "TM_bilateral_wide"
+#> [7] "FBSH_CB_wide" "FBS_wide"
+#> [9] "SCL_wide"
+
+# Get output of a module
+outputs_of("module_xfaostat_L106_FoodMacroNutrient")
+#> [1] "SUA_food_macronutrient_rate"
-# Not evaluated for convenience
-# Load gcamfaostat
-devtools::load_all()
-
-# Load FAO_items from cache
-load_from_cache("aglu/FAO/FAO_items") %>% first() -> FAO_items
-# Print
-head(FAO_items)
-
-# Define a list of input data
-MODULE_INPUTS <- c("Bal_new_all")
-# Load a list of MODULE_INPUTS from cache and assign to their name
-get_data_list(all_data = load_from_cache(MODULE_INPUTS), data_list = MODULE_INPUTS)
-# Print
-head(Bal_new_all)
# Not evaluated for convenience
+# Load gcamfaostat
+devtools::load_all()
+
+# Load FAO_items from cache
+load_from_cache("aglu/FAO/FAO_items") %>% first() -> FAO_items
+# Print
+head(FAO_items)
+
+# Define a list of input data
+MODULE_INPUTS <- c("Bal_new_all")
+# Load a list of MODULE_INPUTS from cache and assign to their name
+get_data_list(all_data = load_from_cache(MODULE_INPUTS), data_list = MODULE_INPUTS)
+# Print
+head(Bal_new_all)