We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f579f7 commit 8b7d904Copy full SHA for 8b7d904
5 files changed
R/input_files.R
@@ -94,7 +94,8 @@ get_file_path <- function(file_alias, force_download = FALSE) {
94
}
95
96
.fetch_file_info <- function(file_alias) {
97
- file_info <- dplyr::filter(.get_input_files_data(), alias == file_alias)
+ input_files <- .read_local_csv("input/raw/input_files.csv")
98
+ file_info <- dplyr::filter(input_files, alias == file_alias)
99
100
if (nrow(file_info) == 0) {
101
stop(stringr::str_glue("There is no file entry with alias {file_alias}"))
@@ -114,8 +115,8 @@ get_file_path <- function(file_alias, force_download = FALSE) {
114
115
c(file_info)
116
117
-.get_input_files_data <- function() {
118
+.read_local_csv <- function(csv_path) {
119
"extdata" |>
- system.file("input/raw/input_files.csv", package = utils::packageName()) |>
120
+ system.file(csv_path, package = utils::packageName()) |>
121
readr::read_csv(show_col_types = FALSE)
122
R/supply_use.R
@@ -13,13 +13,12 @@
13
#' It contains the following columns:
14
#' - `year`: The year in which the recorded event occurred.
15
#' - `area`: The name of the country where the data is from.
16
-#' - `area_code`: FAOSTAT internal code for each country. Equivalences
17
-#' with ISO 3166-1 numeric can be found in the _Area Codes_ CSV from the
18
-#' zip file that can be downloaded from
19
-#' [FAOSTAT](https://www.fao.org/faostat/en/#data/FBS). TODO: Think about
20
-#' this, would be nice to use ISO3 codes but won't be enough for our periods
21
-#' - `item`: Natural language name for the item.
22
-#' - `item_code`: FAOSTAT internal code for each item.
+#' - `proc`: Natural language name of the process taking place.
+#' - `item`: Natural language name of the item taking part in the process.
+#' - `type`: Can have two values:
+#' - `use`: The given item is an input of the process.
+#' - `supply`: The given item is an output of the process.
+#' - `value`: Quantity in tonnes.
23
#'
24
#' @export
25
R/utils.R
@@ -2,28 +2,36 @@
2
utils::globalVariables(
3
c(
4
"alias",
5
+ "area",
6
"area_code",
7
"area_code_p",
8
"balanced_export",
9
"balanced_import",
10
"bilateral_trade",
11
"cf",
12
+ "domestic_supply",
"element",
"Element",
"export",
+ "final_value_processed",
"from_code",
"import",
"Imp/Exp",
"Info_Format",
"item",
"Item",
"item_code",
+ "item_code_to_process",
+ "item_processed",
26
+ "item_to_process",
27
"Name",
28
"No",
29
+ "proc",
30
"processeditem",
31
"product_fraction",
32
"SACO_link",
33
"scaling",
34
+ "seed",
35
"sex",
36
"stock_variation",
37
"Timeline_End",
@@ -34,11 +42,13 @@ utils::globalVariables(
42
"total_trade",
43
"to_code",
44
"Trade",
45
+ "type",
46
"unit",
38
47
"value",
39
48
"Value",
40
49
"value_proc",
41
50
"value_proc_raw",
51
+ "value_to_process",
52
"year",
53
"Year"
54
)
man/build_supply_use.Rd
tests/testthat/test_input_files.R
@@ -1,6 +1,6 @@
1
testthat::test_that("get_file_path fails for non-existent file_alias", {
testthat::local_mocked_bindings(
- .get_input_files_data = function(...) {
+ .read_local_csv = function(...) {
dplyr::tribble(
~extension, ~alias, ~drive_file_id,
"csv", "file_alias_1", "some_id"
@@ -18,7 +18,7 @@ testthat::test_that(
"get_file_path fails for duplicated entries only in filtered rows",
{
"csv", "file_alias_1", "some_id",
@@ -52,7 +52,7 @@ testthat::test_that(
testthat::expect_false(file.exists(destfile))
55
56
57
58
"csv", file_alias, "some_id",
0 commit comments