From 5a97f6f35381e90b21a5dab856d3db75bf4e6388 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Tue, 9 May 2023 16:46:49 +0100 Subject: [PATCH 01/11] adding honey to ntfp-types --- R/NTFP.R | 3 +++ data-raw/ntfp-types.R | 2 ++ 2 files changed, 5 insertions(+) diff --git a/R/NTFP.R b/R/NTFP.R index 0f40ad27..9f676afa 100644 --- a/R/NTFP.R +++ b/R/NTFP.R @@ -141,6 +141,9 @@ fp_proportions_all <- function( prop_column, new_column_name ){ + if (is.null(use_column) | is.null(prop_column)){ + return(tree_aid_df) + } #Checking whether the columns are in the dataset missing_columns <- check_columns_in_data(tree_aid_df, loop_columns = c(use_column, prop_column), diff --git a/data-raw/ntfp-types.R b/data-raw/ntfp-types.R index b721d033..541f3872 100644 --- a/data-raw/ntfp-types.R +++ b/data-raw/ntfp-types.R @@ -219,6 +219,8 @@ fp_products <- list( ) + + ) usethis::use_data(fp_products, overwrite = T) From 2fa837eabfa11c40a01e87effdef9759499d0ce6 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Mon, 22 May 2023 09:56:34 +0100 Subject: [PATCH 02/11] fixes case where unit conversion objects exist in global enviornment --- R/UnitsAndConversions.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/UnitsAndConversions.R b/R/UnitsAndConversions.R index 94cf5fc7..fd7bf275 100644 --- a/R/UnitsAndConversions.R +++ b/R/UnitsAndConversions.R @@ -317,14 +317,14 @@ load_all_db_units <- function(unit_list, database = "rhomis", projectID = "core_ if (unit_name %in% c("crop_name_to_std", "livestock_name_to_std")) { # evaluate the string denoting the variable name to be used - var <- eval(parse(text = unit_name)) + var <- eval(parse(text = paste0("rhomis::",unit_name))) # make dummy tibble conversions <- tibble::as_tibble(list("survey_value" = var, "conversion" = var)) } else { conversions <- make_per_project_conversion_tibble( proj_id_vector = id_rhomis_dataset, - unit_conv_tibble = eval(parse(text = unit_name)) + unit_conv_tibble = eval(parse(text = paste0("rhomis::",unit_name))) ) conversions$unit_type <- unit_name @@ -437,8 +437,8 @@ check_existing_conversions <- function(list_of_df) { new_list <- sapply(names(list_of_df), function(x) { if (x %in% c("crop_name_to_std", "livestock_name_to_std")) { conversion <- tibble::as_tibble(list( - "survey_value" = eval(parse(text = x)), - "conversion" = eval(parse(text = x)) + "survey_value" = eval(parse(text = paste0("rhomis::",x))), + "conversion" = eval(parse(text = paste0("rhomis::",x))) )) df_with_existing_conversions <- dplyr::left_join(list_of_df[[x]], @@ -449,7 +449,7 @@ check_existing_conversions <- function(list_of_df) { dplyr::rename("conversion" = "conversion.y") } else { df_with_existing_conversions <- dplyr::left_join(list_of_df[[x]], - eval(parse(text = x)), + eval(parse(text = paste0("rhomis::",x))), by = ("survey_value" = "survey_value") ) %>% dplyr::select("unit_type", "id_rhomis_dataset", "survey_value", "conversion.y") %>% @@ -482,7 +482,7 @@ check_existing_calorie_conversions <- function(data) { new_list <- sapply(names(list_of_dfs), function(x) { df_with_existing_conversions <- dplyr::left_join(list_of_dfs[[x]], - eval(parse(text = x)), + eval(parse(text = paste0("rhomis::",x))), by = ("survey_value" <- "survey_value") ) %>% dplyr::select("unit_type", "id_rhomis_dataset", "survey_value", "conversion.y") %>% @@ -580,7 +580,7 @@ load_local_units <- function(units_folder, id_rhomis_dataset, unit_type="primary # if (unit_type=="primary"){ # unit_list <- as.character(pkg.env$unit_file_names) # } - # + # # if (unit_type=="secondary"){ # unit_list <- names(pkg.env$secondary_units) # } @@ -604,7 +604,7 @@ load_local_units <- function(units_folder, id_rhomis_dataset, unit_type="primary if (unit_file %in% c("crop_name_to_std", "livestock_name_to_std")) { # evaluate the string denoting the variable name to be used - var <- eval(parse(text = unit_file)) + var <- eval(parse(text = paste0("rhomis::",unit_file))) # make dummy tibble conversions <- tibble::as_tibble(list("survey_value" = var, "conversion" = var)) @@ -613,7 +613,7 @@ load_local_units <- function(units_folder, id_rhomis_dataset, unit_type="primary unit_conv_tibble = conversions ) } else { - var <- eval(parse( text = unit_file)) + var <- eval(parse( text = paste0("rhomis::",unit_file))) # make dummy tibble conversions <- make_per_project_conversion_tibble( @@ -682,7 +682,7 @@ load_calorie_conversions <- function(base_folder, id_rhomis_dataset) { # create conversion tibble calorie_conversion <- make_per_project_conversion_tibble( proj_id_vector = id_rhomis_dataset, - unit_conv_tibble = eval(parse(text = paste0(produce, "_calories"))) + unit_conv_tibble = eval(parse(text = paste0("rhomis::",produce, "_calories"))) ) } From 1e1a271a92e1710775102bf6a2720f8264a7d099 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Wed, 24 May 2023 17:38:51 +0100 Subject: [PATCH 03/11] fixes null conversion --- R/ValueCalculations.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/ValueCalculations.R b/R/ValueCalculations.R index 70d58366..3e4765ad 100644 --- a/R/ValueCalculations.R +++ b/R/ValueCalculations.R @@ -115,8 +115,8 @@ value_calculations <- function(processed_data, ) if ("mean_crop_price_lcu_per_kg" %in% names(prices) & length(missing_columns) == 0) { - if (!is.null(prices[["mean_crop_price_lcu_per_kg"]]) & nrow(prices[["mean_crop_price_lcu_per_kg"]])>0){ - + if (!is.null(prices[["mean_crop_price_lcu_per_kg"]]) ){ + if(nrow(prices[["mean_crop_price_lcu_per_kg"]])>0){ # processed_data <- remove_existing_loop_if_exists(processed_data, "value_crop_consumed_lcu") processed_data <- value_or_calorie_calculations_item_consumed( @@ -131,6 +131,7 @@ value_calculations <- function(processed_data, data = processed_data, name_column = "crop_name", column_prefixes = "value_crop_consumed_lcu", types = "num" )[[1]] + } } From 4de3d7944afc0d491048689fb88b871c6e877ec3 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Wed, 24 May 2023 18:25:39 +0100 Subject: [PATCH 04/11] fixes issue of no year and no currency --- .github/workflows/R-CMD-check.yaml | 2 +- R/CurrencyConversion.R | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d48ecdde..78d2d3a5 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -33,7 +33,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - if: runner.os == 'macos' run: | diff --git a/R/CurrencyConversion.R b/R/CurrencyConversion.R index b4acc211..efdc168b 100644 --- a/R/CurrencyConversion.R +++ b/R/CurrencyConversion.R @@ -184,7 +184,9 @@ convert_all_currencies <- function(data, country_column = "country", year_column # "year"=c("2016","2016","2021", "2014", "2016", NA, "2020") # ))) subset_data <- data %>% dplyr::select(c(country_column, year_column)) - combinations <- tibble::as_tibble(table(subset_data)) %>% + + + combinations <- tibble::as_tibble(table(subset_data,useNA="always")) %>% dplyr::filter(n > 0) %>% dplyr::select(-c("n")) @@ -193,8 +195,8 @@ convert_all_currencies <- function(data, country_column = "country", year_column for (i in 1:nrow(combinations)) { conversion_data <- currency_conversion_factor(year=combinations[i, year_column], country_code=combinations[i, country_column]) - conversion_factors <- c(conversion_factors, conversion_data["conversion_factor"]) - conversion_years <- c(conversion_years, conversion_data["conversion_year"]) + conversion_factors <- c(conversion_factors, conversion_data[["conversion_factor"]]) + conversion_years <- c(conversion_years, conversion_data[["conversion_year"]]) } combinations$conversion_factor <- unlist(conversion_factors) @@ -206,7 +208,9 @@ convert_all_currencies <- function(data, country_column = "country", year_column data[[year_column]] <- as.numeric(data[[year_column]]) combinations$year <- as.numeric(combinations$year) - data_with_conversions <- dplyr::left_join(data, combinations, by = matching_list) + combinations <- combinations[!duplicated(combinations),] + + data_with_conversions <- dplyr::left_join(data, combinations, by = matching_list,) data <- add_column_after_specific_column( data = data, From 6f3dd68d76750d0959ebb71ec055cbec905fa61c Mon Sep 17 00:00:00 2001 From: l-gorman Date: Wed, 24 May 2023 19:43:54 +0100 Subject: [PATCH 05/11] fixes actions error for ubuntu runs --- .github/workflows/R-CMD-check.yaml | 4 +++- .github/workflows/deploy_docs.yaml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 78d2d3a5..db81ab0f 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -42,7 +42,9 @@ jobs: brew services start mongodb-community@5.0 - if: runner.os == 'linux' - run: sudo systemctl restart mongod + run: | + sudo systemctl restart mongod + sudo apt-get install libcurl4-openssl-dev -y - uses: r-lib/actions/setup-r@v2 with: diff --git a/.github/workflows/deploy_docs.yaml b/.github/workflows/deploy_docs.yaml index 8ce03c82..e17b7112 100644 --- a/.github/workflows/deploy_docs.yaml +++ b/.github/workflows/deploy_docs.yaml @@ -31,6 +31,9 @@ jobs: - uses: r-lib/actions/setup-r@v2 - uses: r-lib/actions/setup-pandoc@v1 + - if: runner.os == 'linux' + run: | + sudo apt-get install libcurl4-openssl-dev -y - name: Query dependencies run: | From 50898e7515be4163170a7c5ffc17f8adf45c2766 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Wed, 24 May 2023 20:15:44 +0100 Subject: [PATCH 06/11] fixes actions error for ubuntu runs --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index db81ab0f..f9eacad1 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -44,7 +44,7 @@ jobs: - if: runner.os == 'linux' run: | sudo systemctl restart mongod - sudo apt-get install libcurl4-openssl-dev -y + sudo apt-get install libcurl4-openssl-dev libssl-dev libsasl2-dev libharfbuzz-dev libfribidi-dev -y - uses: r-lib/actions/setup-r@v2 with: From 36ecad4388ecb7a1dd32ccf51a8a657b23386fa7 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Wed, 24 May 2023 21:02:41 +0100 Subject: [PATCH 07/11] fixes actions error for ubuntu runs --- .github/workflows/deploy_docs.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_docs.yaml b/.github/workflows/deploy_docs.yaml index e17b7112..d8488504 100644 --- a/.github/workflows/deploy_docs.yaml +++ b/.github/workflows/deploy_docs.yaml @@ -33,7 +33,9 @@ jobs: - if: runner.os == 'linux' run: | - sudo apt-get install libcurl4-openssl-dev -y + sudo apt-get install libcurl4-openssl-dev libssl-dev libsasl2-dev libharfbuzz-dev libfribidi-dev -y + + - name: Query dependencies run: | From 6f7e22da4269df2e95278ef82c5102a6df3f0a70 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Fri, 26 May 2023 15:37:14 +0100 Subject: [PATCH 08/11] adds preprocessing so NTFP honey is included in NTFP calculations --- NAMESPACE | 1 + R/NTFP.R | 94 ++++++++++++++++++++++++++++++++++++++ R/RunAll.R | 10 ++-- data-raw/ntfp-types.R | 32 +++++++++++++ data/fp_products.rda | Bin 913 -> 988 bytes man/fp_products.Rd | 2 +- man/ntfp_preprocessing.Rd | 22 +++++++++ 7 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 man/ntfp_preprocessing.Rd diff --git a/NAMESPACE b/NAMESPACE index 1ae12460..869b1075 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -167,6 +167,7 @@ export(modify_loop_column_names) export(modify_loop_name) export(new_indicator) export(ntfp_calories_and_values) +export(ntfp_preprocessing) export(ntfp_sold_and_consumed_calculation) export(ntfp_total_individual) export(ntfp_totals) diff --git a/R/NTFP.R b/R/NTFP.R index 9f676afa..f1568859 100644 --- a/R/NTFP.R +++ b/R/NTFP.R @@ -1,4 +1,98 @@ +#' NTFP Preprocessing +#' +#' For forest product surveys, honey +#' does not fit into the conventional NTFP loops. +#' This means we cannot make use of existing NTFP calculations. +#' +#' This script adds an "extra loop" to a NTFP dataset, one +#' that allows for the calculation of honey based-indicators. +#' +#' @param tree_aid_df A dataset containing (or not) questions from NTFP modules +#' @param fp_products A list of. Default is the list contained within the R-package +#' +#' @return +#' @export +#' +#' @examples +ntfp_preprocessing <-function(tree_aid_df, + fp_products=fp_products){ + + + missing_columns <- suppressWarnings(check_columns_in_data(tree_aid_df, + loop_columns = "fp_name", + individual_columns = "id_rhomis_dataset", + warning="Won't conduct NTFP preprocessing, NTFP module not present")) + + if(length(missing_columns)){ + + return(tree_aid_df) + + } + + fp_column_numbers <- find_number_of_loops(tree_aid_df, "fp_name") + extra_loop <- fp_column_numbers + 1 + + non_honey_columns <- fp_products[names(fp_products)!="honey"] + + non_honey_columns <- lapply(non_honey_columns, function(x){ + x <- x[names(x) %in% "base_name"==F] + }) + non_honey_columns <- as.character(unlist(non_honey_columns)) + non_honey_columns <- unique(non_honey_columns) + + missing_ntfp_cols <- suppressWarnings(check_columns_in_data(tree_aid_df,loop_columns = non_honey_columns)) + non_honey_columns <- non_honey_columns[non_honey_columns %in% missing_ntfp_cols==F] + + new_non_honey_columns <- paste0(non_honey_columns,"_",extra_loop) + + + dummy_honey_columns <- fp_products[names(fp_products)=="honey"] + dummy_honey_columns <- as.character(unlist(dummy_honey_columns)) + dummy_honey_columns <- dummy_honey_columns[!is.na(dummy_honey_columns)] + new_dummy_honey_columns <- lapply(c(1:fp_column_numbers),function(i){ + paste0(dummy_honey_columns,"_",i) + }) %>% unlist() + new_dummy_honey_columns <- new_dummy_honey_columns[new_dummy_honey_columns %in% new_non_honey_columns==F] + + new_columns <- c(new_dummy_honey_columns,new_non_honey_columns) + new_dummy_columns <- new_columns[duplicated(new_columns)==F] + + new_dummy_columns <- sapply(new_dummy_columns,function(x){ + rep(NA,nrow(tree_aid_df)) + },simplify=F) %>% dplyr::bind_cols() + + new_dummy_columns <- new_dummy_columns[colnames(new_dummy_columns) %in% colnames(tree_aid_df)==F] + + tree_aid_df <- dplyr::bind_cols(tree_aid_df,new_dummy_columns) + + + + real_honey_columns <- fp_products[names(fp_products)=="honey"] + real_honey_columns <- as.character(unlist(real_honey_columns)) + real_honey_columns <- real_honey_columns[!is.na(real_honey_columns)] + + real_honey_columns <- sapply(real_honey_columns,function(x){ + if (x %in% colnames(tree_aid_df)){ + return(tree_aid_df[[x]]) + }else{ + return(rep(NA,nrow(tree_aid_df))) + } + + },simplify=F) %>% dplyr::bind_cols() + colnames(real_honey_columns) <- paste0(colnames(real_honey_columns),"_",extra_loop) + + real_honey_columns <- real_honey_columns[colnames(real_honey_columns) %in% colnames(tree_aid_df)==F] + + + tree_aid_df <- dplyr::bind_cols(tree_aid_df,real_honey_columns) + + + + return(tree_aid_df) + +} + #' Convert NTFP Units #' diff --git a/R/RunAll.R b/R/RunAll.R index db8701b2..07fb00c4 100644 --- a/R/RunAll.R +++ b/R/RunAll.R @@ -169,13 +169,13 @@ load_rhomis_csv <- function(file_path, # read in the input csv file - rhomis_data <- readr::read_csv(file_path, col_types = readr::cols(), - na = c("na","n/a", "-999", "-99", "NA"), + rhomis_data <- readr::read_csv(file_path, col_types = readr::cols(), + na = c("na","n/a", "-999", "-99", "NA"), locale = readr::locale(encoding = "UTF8"), show_col_types=F) # simplify column names to more readable format - newcolnames <- tolower(clean_column_names(colnames(rhomis_data))) + newcolnames <- tolower(clean_column_names(colnames(rhomis_data))) colnames(rhomis_data) <- newcolnames # ensure all data entries are lower case for consistency / easier data analysis @@ -211,6 +211,10 @@ load_rhomis_csv <- function(file_path, overwrite = overwrite ) + # Checks whether NTFP columns exist, and does some preprocessing to + # Reformat data + rhomis_data <- ntfp_preprocessing(rhomis_data) + return(rhomis_data) } diff --git a/data-raw/ntfp-types.R b/data-raw/ntfp-types.R index 541f3872..9a520c18 100644 --- a/data-raw/ntfp-types.R +++ b/data-raw/ntfp-types.R @@ -1,6 +1,38 @@ fp_products <- list( + honey=list( + fp_name = "fp_name", + base_name="honey", + + #Info needed for shea_butter calculations + amount = "honey_amount", + amount_units = "honey_amount_units", + amount_units_other = "honey_amount_units_other", + + # Info needed for proportions calculations + use_column = "honey_use", + sold_prop_column = "honey_sold_prop", + consumed_column = "honey_consumed_prop", + processed_column = NULL, + + income_column = "honey_sold_income", + income_frequency = "honey_sold_price_quantityunits", + sold_frequency_other_column = "honey_sale_freq_units_other", + + consume_gender=NULL, + sell_gender="honey_who_sell", + sell_income_gender="honey_sold_income_who", + + processed_sold_column = NULL, + processed_eaten_column = NULL, + + process_sold_income_column = NULL, + process_sold_frequency_column = NULL, + process_sold_frequency_other_column = NULL + ), + + fruit=list( base_name="fruit", fp_name = "fp_name", diff --git a/data/fp_products.rda b/data/fp_products.rda index 720ae1a74d3f647577b3dadc65232c8f452b4d25..046726ed9edab88eacccf78c37e3e6cf0aab9ad1 100644 GIT binary patch literal 988 zcmV<210(!GT4*^jL0KkKS&z`79{>l||A7Dh|NrlR5C8-K5J120|DXT?&;>omf$3?^ z9#yrsnz{)pr?jD?YI={<^roMwH1L^Ci8N^RgGZR=Onlv_{wE>}^6%wYAh#4BD)XC)!DvKLM zMuNmqMxjum#?fO1B^5V0=ub3BA!I~_kz_KGNRJ=i5fIf1h&6cc@A2&F>%BYM>S?Nq zsivwcT_;SlBTArEsTQIX0?hEYzP(*H$Z?Z0ueC*oeaRbD5n93 zx4yh~&UZdCWyOZuJ1oWpBIiS$5hMbY3Nb(%AW03~A|43s3Mi=svRWv?Ieg>1ScMd8 zqF}z*SbwQD!fPW~&{0%-_TZm1hcrXhC($G~BT7q0piGz*>9TwItcOfQZ-uY|mZXDW zWuDVd11ZgYbzskZ6;k0e1$nKuw}<77hiqS4{jzDxlCdfTk!ng(80F)M@wM-hItPNp z1s*|A;GTj!(nQE|5$XDe)|4m+URM}hR%d=P2zNgoN-oD&OMqB_Nb`6iKp4u53MLAL zMo}Wflhh<=C{zQ1gH)`KV`ct}QsryTmM`3RU|5jAQCb)Bq~MM`2cJIh!tbjI>lZ+ zJ{axp?(+Qnd8CF46OeU8QOi^xKTHBh0~J+ORaI40TahC&-Vz;YJn177SZ0uTW(yQn z5xOjp_d_fq6@pp`yrEzUYf0=&Wk_y`B_5&BN3kbS8V3#gX_Q$-p=99?Y?1CC_`8xR K!i0o=g%J2fTBfZ4 literal 913 zcmV;C18)36T4*^jL0KkKSy85)iGsBl!+dNxt z8#WtRF0hL;fd@*)EJ(2kv5N??F<6Bx5Q_l1#0aq5teRF+D;CqKi8v`kB101)rUgc? zrjmnLVO6cGZ--XzUvo8@>h&n9y-F*17G(Sjb-KmpUPZdai?M9GR}8deGAk9ru$Te7 zb7o9dB1O8zvd~4k#4=itVA76(Z$MnfL>ap?GGa3~a#u|wm}J?mu;)Ngfn#V|5?U@G zc1KQGXv$(#FUeHd***%mwqC(B!y+canK8*9)KOI5&%28)jFQ@%TgWCfaRJt(Yn9fl4Ta?=Y8HcJ zo^D$6tX3*b2Q6#XE`CK7Puw!gYek#4>!L`C8oNO~Rw5V>(OD*yft998GNtL1Y*E1@ z&F%nhD8bBt=T<5?z_RojcsR9mTK!w{cTrZwtCP=4I296vRL-D;A}zEM$R|3Z1rD`t zAbQtg*x0a5tH`@n^&RXOsdP~09nxS Date: Fri, 26 May 2023 15:57:20 +0100 Subject: [PATCH 09/11] adds honey preprocessing --- R/NTFP.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/NTFP.R b/R/NTFP.R index f1568859..61c4bd5e 100644 --- a/R/NTFP.R +++ b/R/NTFP.R @@ -9,14 +9,13 @@ #' that allows for the calculation of honey based-indicators. #' #' @param tree_aid_df A dataset containing (or not) questions from NTFP modules -#' @param fp_products A list of. Default is the list contained within the R-package #' #' @return #' @export #' #' @examples -ntfp_preprocessing <-function(tree_aid_df, - fp_products=fp_products){ +ntfp_preprocessing <-function(tree_aid_df + ){ missing_columns <- suppressWarnings(check_columns_in_data(tree_aid_df, @@ -24,7 +23,7 @@ ntfp_preprocessing <-function(tree_aid_df, individual_columns = "id_rhomis_dataset", warning="Won't conduct NTFP preprocessing, NTFP module not present")) - if(length(missing_columns)){ + if(length(missing_columns)>0){ return(tree_aid_df) @@ -80,6 +79,10 @@ ntfp_preprocessing <-function(tree_aid_df, } },simplify=F) %>% dplyr::bind_cols() + + extra_fp_col <- paste0("fp_name_",extra_loop) + tree_aid_df[[extra_fp_col]][!is.na(real_honey_columns$honey_amount)] <- "bees" + colnames(real_honey_columns) <- paste0(colnames(real_honey_columns),"_",extra_loop) real_honey_columns <- real_honey_columns[colnames(real_honey_columns) %in% colnames(tree_aid_df)==F] From d9ed5c93d9cb33fe44d778b7c0aef35dc5f276b1 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Thu, 29 Jun 2023 13:21:40 +0100 Subject: [PATCH 10/11] updates tibble function to account for changes in R-devel v 4.3 --- renv.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/renv.lock b/renv.lock index 6476d82a..db0cbcd7 100644 --- a/renv.lock +++ b/renv.lock @@ -1,6 +1,6 @@ { "R": { - "Version": "4.2.0", + "Version": "4.3.1", "Repositories": [ { "Name": "CRAN", @@ -270,10 +270,10 @@ }, "gert": { "Package": "gert", - "Version": "1.6.0", + "Version": "1.9.2", "Source": "Repository", "Repository": "CRAN", - "Hash": "98c014c4c933f23ea5a0321a4d0b588b" + "Hash": "9122b3958e749badb5c939f498038b57" }, "getopt": { "Package": "getopt", @@ -452,10 +452,10 @@ }, "openssl": { "Package": "openssl", - "Version": "2.0.2", + "Version": "2.0.6", "Source": "Repository", "Repository": "CRAN", - "Hash": "6d3bef2e305f55c705c674653c7d7d3d" + "Hash": "0f7cd2962e3044bb940cca4f4b5cecbe" }, "optparse": { "Package": "optparse", @@ -466,10 +466,10 @@ }, "pillar": { "Package": "pillar", - "Version": "1.7.0", + "Version": "1.9.0", "Source": "Repository", "Repository": "CRAN", - "Hash": "51dfc97e1b7069e9f7e6f83f3589c22e" + "Hash": "15da5a8412f317beeee6175fbc76f4bb" }, "pkgbuild": { "Package": "pkgbuild", @@ -683,10 +683,10 @@ }, "tibble": { "Package": "tibble", - "Version": "3.1.7", + "Version": "3.2.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "08415af406e3dd75049afef9552e7355" + "Hash": "a84e2cc86d07289b3b6f5069df7a004c" }, "tidyr": { "Package": "tidyr", @@ -739,10 +739,10 @@ }, "vctrs": { "Package": "vctrs", - "Version": "0.4.1", + "Version": "0.6.3", "Source": "Repository", "Repository": "CRAN", - "Hash": "8b54f22e2a58c4f275479c92ce041a57" + "Hash": "d0ef2856b83dc33ea6e255caf6229ee2" }, "vroom": { "Package": "vroom", From 52e4a09ee78794a6d5d4da6cb11c44d8077a64b1 Mon Sep 17 00:00:00 2001 From: l-gorman Date: Fri, 7 Jul 2023 08:04:31 +0100 Subject: [PATCH 11/11] updates purrr to fix warnings --- R/config_package_vars.R | 8 +++++--- man/ntfp_preprocessing.Rd | 4 +--- renv.lock | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/R/config_package_vars.R b/R/config_package_vars.R index e644f779..1fd1059b 100644 --- a/R/config_package_vars.R +++ b/R/config_package_vars.R @@ -73,7 +73,9 @@ set_conversion_file_names <- function(){ "leaves_sold_frequency", "bark_sold_frequency", "roots_sold_frequency", - "gum_sold_frequency" + "gum_sold_frequency", + "shea_butter_sold_frequency", + "shea_butter_sold_amount_units_other" ) @@ -132,8 +134,8 @@ set_conversion_file_names <- function(){ eggs_sold_price_timeunits = c("eggs_sold_price_timeunits_other"), fertiliser_units = c("fertiliser_units_other"), - fp_amount_units = c("fruit_amount_units","nut_amount_units","leaves_amount_units","bark_amount_units","roots_amount_units", "gum_amount_units"), - fp_income_units = c("fruit_sold_frequency","nut_sold_frequency","leaves_sold_frequency","bark_sold_frequency","roots_sold_frequency", "gum_sold_frequency") + fp_amount_units = c("fruit_amount_units","nut_amount_units","leaves_amount_units","bark_amount_units","roots_amount_units", "gum_amount_units", "shea_butter_sold_frequency"), + fp_income_units = c("fruit_sold_frequency","nut_sold_frequency","leaves_sold_frequency","bark_sold_frequency","roots_sold_frequency", "gum_sold_frequency","shea_butter_sold_amount_units_other") ) diff --git a/man/ntfp_preprocessing.Rd b/man/ntfp_preprocessing.Rd index 99b97693..bcff4abb 100644 --- a/man/ntfp_preprocessing.Rd +++ b/man/ntfp_preprocessing.Rd @@ -4,12 +4,10 @@ \alias{ntfp_preprocessing} \title{NTFP Preprocessing} \usage{ -ntfp_preprocessing(tree_aid_df, fp_products = fp_products) +ntfp_preprocessing(tree_aid_df) } \arguments{ \item{tree_aid_df}{A dataset containing (or not) questions from NTFP modules} - -\item{fp_products}{A list of. Default is the list contained within the R-package} } \description{ For forest product surveys, honey diff --git a/renv.lock b/renv.lock index db0cbcd7..394e6a23 100644 --- a/renv.lock +++ b/renv.lock @@ -137,10 +137,10 @@ }, "cli": { "Package": "cli", - "Version": "3.3.0", + "Version": "3.6.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "23abf173c2b783dcc43379ab9bba00ee" + "Hash": "89e6d8219950eac806ae0c489052048a" }, "clipr": { "Package": "clipr", @@ -403,10 +403,10 @@ }, "lifecycle": { "Package": "lifecycle", - "Version": "1.0.1", + "Version": "1.0.3", "Source": "Repository", "Repository": "CRAN", - "Hash": "a6b6d352e3ed897373ab19d8395c98d0" + "Hash": "001cecbeac1cff9301bdc3775ee46a86" }, "lubridate": { "Package": "lubridate", @@ -536,10 +536,10 @@ }, "purrr": { "Package": "purrr", - "Version": "0.3.4", + "Version": "1.0.1", "Source": "Repository", "Repository": "CRAN", - "Hash": "97def703420c8ab10d8f0e6c72101e02" + "Hash": "d71c815267c640f17ddbf7f16144b4bb" }, "rappdirs": { "Package": "rappdirs",