You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a script which pulls related indicators for several CCGs in to a list - this was previously working fine however since Friday last week I've been experiencing this error code which happens randomly part way through the for loop.
At whatever indicator I get the error message, I've tried running the internals of the for loop once individually with that indicator and it works fine. There's nothing changed about the code so I'm not sure what's going wrong - any help would be appreciated.
Code:
geog <- c("E38000220", "E38000046", "E38000144", "E38000191", "E38000210", "E38000038", "E38000164", "E38000195", "E38000078", "E38000139", "E38000166", "E38000211", "E38000147", "E38000183", "E38000028", "E38000053", "E38000126", "E38000153", "E38000173", "E38000175"
)
indicators <- c(241, 92588, 90672, 92950, 92951, 92952, 92878, 92879, 90691, 90692, 92882, 92883, 90696, 92886, 92887, 90694, 90702, 91238, 92828, 92830, 92832, 92834, 92836, 92842, 92870, 92874, 93001, 92829, 92831, 92833, 92835, 92837, 92843, 92871, 92875, 93003, 93245, 93246, 93244, 93247, 93248, 93049, 93047, 93051, 90700)
result_list <- vector("list", length = length(indicators))
names(result_list) <- indicators
for (indicator_number in indicators) {
# load the data once per indicator
tmpDF <- fingertips_data(IndicatorID = indicator_number, AreaTypeID = c(152, 154, 165))
# retrieve the rows corresp. to max per geog
out <- t(vapply(seq_along(geog), function (s) {
row_geog <- which(.subset2(tmpDF, which(names(tmpDF) == 'AreaCode')) == geog[s])
row_max <- which.max(.subset2(tmpDF, which(names(tmpDF) == 'TimeperiodSortable'))[row_geog])
res <- tmpDF[row_geog,c("Timeperiod","Value", "Count", "Denominator")][row_max,]
res <- c(Timeperiod = res$Timeperiod, Value = res$Value,
Count = res$Count, Denominator = res$Denominator)
if (length(res) == 0) res <- c(Timeperiod = NA_character_, Value = NA_character_,
Count = NA_character_, Denominator = NA_character_)
return (res)
}, character(4)))
# save result for indicator[k]
result_list[[as.character(indicator_number)]] <- data.frame(indicator = indicator_number,
geog,
Timeperiod = out[,1],
Value = as.numeric(out[,2]),
Count = as.numeric(out[,3]),
Denominator = as.numeric(out[,4]),
stringsAsFactors = FALSE)
print(paste0(indicator_number, ": success"))
}
The text was updated successfully, but these errors were encountered:
Hi @VictorYuNHS - thanks for reporting this. I've been seeing this too a lot recently. There is an issue with the API at the moment. I've reported this to the website developers. I'm afraid I don't know what to recommend to do in the meantime other than keep trying.
Hi @VictorYuNHS - we're looking into improving our servers. This might take some time.
In the meantime, I've modified the development version package slightly to retry API calls 5 times when they are getting time outs. This should help users in similar situations as you.
Hi,
I have a script which pulls related indicators for several CCGs in to a list - this was previously working fine however since Friday last week I've been experiencing this error code which happens randomly part way through the for loop.
At whatever indicator I get the error message, I've tried running the internals of the for loop once individually with that indicator and it works fine. There's nothing changed about the code so I'm not sure what's going wrong - any help would be appreciated.
Code:
The text was updated successfully, but these errors were encountered: