From 7539e18d1ed51f224dfcd938bf91227b5d3b96a4 Mon Sep 17 00:00:00 2001 From: "Zhao, Xin" Date: Thu, 4 Apr 2024 12:55:31 -0400 Subject: [PATCH] update page minor format improvement --- docs/articles/vignette_preparing_data.html | 143 ++++++++--------- docs/articles/vignette_processing_flow.html | 160 ++++++++++---------- vignettes/vignette_preparing_data.Rmd | 3 +- vignettes/vignette_processing_flow.Rmd | 5 +- 4 files changed, 164 insertions(+), 147 deletions(-) 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 @@

4. Check local raw data info @@ -518,11 +523,11 @@

4. Check local raw data info

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")

5. Load raw data into package @@ -536,8 +541,8 @@

5. Load raw data into package
-# 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)

6. Update the Prebulit data diff --git a/docs/articles/vignette_processing_flow.html b/docs/articles/vignette_processing_flow.html index ed687a68..46516db4 100644 --- a/docs/articles/vignette_processing_flow.html +++ b/docs/articles/vignette_processing_flow.html @@ -112,7 +112,7 @@

Examples

-# 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)

diff --git a/vignettes/vignette_preparing_data.Rmd b/vignettes/vignette_preparing_data.Rmd index 7e1d0dc0..c1e40cab 100644 --- a/vignettes/vignette_preparing_data.Rmd +++ b/vignettes/vignette_preparing_data.Rmd @@ -22,7 +22,8 @@ knitr::opts_chunk$set( The `gcamfaostat` tool is designed to streamline the processing and synthesis of raw data sourced from [FAOSTAT](https://www.fao.org/faostat/en/#data). The initial phase of this process involves data procurement, with a critical awareness of FAOSTAT's ongoing data updates. These updates encompass a spectrum of improvements, including, e.g., the addition of historical data for new countries and items, data completion for previously missing entries, and refinements such as changes in country nomenclature. This dynamic data landscape underscores the need for a robust and adaptable approach in the `gcamfaostat` workflow. Here we describe a few key functions in `gcamdatafaostat` created to procure the raw data and facilitate the processing. When `gcamfaostat` is downloaded, preprocessed FAOSTAT data, i.e., output of the `xfaostat_L101_RawDataPreProc*` modules, are stored in the [Prebuilt Data](https://github.com/JGCRI/gcamfaostat/blob/main/data/PREBUILT_DATA.rda) of the package. -* The package can be run with using those data, but make sure `Process_Raw_FAO_Data <- FALSE` in `constants.R`. + +* The package can be run with using those data, but make sure `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 [@xin_zhao_2023_8260225]. diff --git a/vignettes/vignette_processing_flow.Rmd b/vignettes/vignette_processing_flow.Rmd index 362d1957..41915fbf 100644 --- a/vignettes/vignette_processing_flow.Rmd +++ b/vignettes/vignette_processing_flow.Rmd @@ -58,13 +58,16 @@ As an illustrative example, the first tier comprises 168 commodities, generated As gcamfaostat is built upon the foundation of `gcamdata` and leverages the powerful drake framework, inheriting functions designed for tracking data flows. In the following, we will delve into several key features that exemplify the strengths of this integration. [`info`](https://jgcri.github.io/gcamfaostat/reference/info.html) + * The function returns information of an object, including name, metadata information, precursors and dependents. [`dstrace`](https://jgcri.github.io/gcamfaostat/reference/dstrace.html) + * The function is able to trace data flows by providing precursors and dependents of an object recursively. [`load_from_cache`](https://jgcri.github.io/gcamfaostat/reference/load_from_cache.html) -* 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. + +* 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`](https://jgcri.github.io/gcamfaostat/reference/get_data_list.html) can be used to assign each object in the list to a data frame.