diff --git a/FAOSTAT/R/faostat_bulk_download.R b/FAOSTAT/R/faostat_bulk_download.R index eaaca2a..26a4194 100644 --- a/FAOSTAT/R/faostat_bulk_download.R +++ b/FAOSTAT/R/faostat_bulk_download.R @@ -90,7 +90,7 @@ read_faostat_bulk <- function(zip_file_name, # Rename columns to lower case # and replace non alphanumeric characters by underscores. names(df) <- gsub("[^[:alnum:]]", "_", tolower(names(df))) - if(rename_element){ + if(rename_element & "element" %in% names(df)){ df$element <- gsub("[^[:alnum:]]","_",tolower(df$element)) } return(df)