datazoompuc / datazoom.amazonia

Simplify access to data from the Brazilian Amazon
Other
52 stars 7 forks source link

DATASUS - fix download error #220

Closed IgorRigolon closed 11 months ago

IgorRigolon commented 11 months ago

There was an extremely small mistake in the download.R code for DATASUS.

The DATASUS files are named things like DOAM2010.DBC. And we define the file_extension via file_extension <- sub(".*\\.", ".", path), which returns ".DBC".

And the code to actually read the data is

if (file_extension == ".dbc") {
      dat <- read.dbc(temp)
}

But the file_extension wasn't ".dbc", it was ".DBC", so it just wasn't read, and the dat object didn't exist.

All I had to do to fix it was

file_extension <- sub(".*\\.", ".", path) %>%
    tolower()

to make all file extensions lowercase.