Error in load_datasus
Closed this issue · 2 comments
giuliaimbu commented
Apparently the object 'dat' can´t be found.
dat <- param$filenames %>%
purrr::imap(
function(file_name, iteration) {
base::message(paste0("Downloading file ", file_name, " (", iteration, " out of ", length(filenames), ")"))
external_download(
source = "datasus",
dataset = param$dataset,
skip_rows = param$skip_rows,
file_name = file_name
)
}
)
names(dat) <- filenames
The problem in datasus.R code seems to be here:
dat <- param$filenames %>%
purrr::imap(
function(file_name, iteration) {
base::message(paste0("Downloading file ", file_name, " (", iteration, " out of ", length(filenames), ")"))
external_download(
source = "datasus",
dataset = param$dataset,
skip_rows = param$skip_rows,
file_name = file_name
)
}
)
names(dat) <- filenames
IgorRigolon commented
I don't understand what the error is when trying to run ``load_datasus(...)`
giuliaimbu commented
I tried running load_datasus again using the code:
# download raw data for the year 2010 in the state of AM.
data <- load_datasus(dataset = "datasus_sim_do",
time_period = 2010,
states = "AM",
raw_data = TRUE)
# download treated data with the number of deaths by cause in AM and PA.
data <- load_datasus(dataset = "datasus_sim_do",
time_period = 2010,
states = c("AM", "PA"),
raw_data = FALSE)
# download treated data with the number of deaths by cause in AM and PA
# keeping all individual variables.
data <- load_datasus(dataset = "datasus_sim_do",
time_period = 2010,
states = c("AM", "PA"),
raw_data = FALSE,
keep_all = TRUE)
The same message appears for these 3 chunks of code:
Error in `map2()`:
ℹ In index: 1.
Caused by error in `external_download()`:
! object 'dat' not found
Run `rlang::last_trace()` to see where the error occurred.
> data <- load_datasus(dataset = "datasus_sim_do",
+ time_period = 2010,
+ states = c("AM", "PA"),
+ raw_data = FALSE,
+ keep_all = TRUE)