Skip to content

Commit

Permalink
Document the rename_element argument to the read_faostat_bulk function
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrougieux committed Jan 5, 2022
1 parent c43f1f4 commit 09aa7ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions FAOSTAT/R/faostat_bulk_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ download_faostat_bulk <- function(url_bulk, data_folder){
#' @rdname download_faostat_bulk
#' @param zip_file_name character name of the zip file to read
#' @param encoding parameter passed to `read.csv`.
#' @param rename_element
#' @param rename_element boolean Rename the element column to snake case. To
#' facilitate the use of elements as column names later when the data frame
#' gets reshaped to a wider format. Replace non alphanumeric characters by
#' underscores.
#' @return data frame of FAOSTAT data
#' @export
read_faostat_bulk <- function(zip_file_name,
Expand All @@ -88,9 +91,6 @@ read_faostat_bulk <- function(zip_file_name,
# and replace non alphanumeric characters by underscores.
names(df) <- gsub("[^[:alnum:]]", "_", tolower(names(df)))
if(rename_element){
# Rename the element column to snake case. To facilitate the use of elements
# as column names later when the data frame gets reshaped to a wider format.
# Replace non alphanumeric characters by underscores.
df$element <- gsub("[^[:alnum:]]","_",tolower(df$element))
}
return(df)
Expand Down

0 comments on commit 09aa7ff

Please sign in to comment.