Skip to content

Commit

Permalink
Only rename the element column if it is present in the data frame fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrougieux committed Feb 13, 2023
1 parent 6f19562 commit b645e19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion FAOSTAT/R/faostat_bulk_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b645e19

Please sign in to comment.