Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses subscript out of bounds error #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions R/owid.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ globalVariables(c("name", "code", "years", "values", "entity", "year", ".", "tit
#'
check_internet <- function(url) {
out <- FALSE
url_status <- httr::GET(url = url)
if (!curl::has_internet()) {
message("No internet connection available: returning blank data.table")
} else if (httr::http_error(url)) {
} else if (httr::http_error(url_status)) {
message(paste0("Could not connect to ", url, ", site may be down. Returning blank data.table"))
} else {
out <- TRUE
Expand Down Expand Up @@ -153,9 +154,9 @@ owid <- function(chart_id = NULL, rename = NULL, tidy.date = TRUE, ...) {
colnames(out)[4] <- if (!is.null(display_name)) display_name else metadata$name

data_info <- vector(mode = "list", length = 1)
data_info[[1]]$source <- metadata$source
data_info[[1]]$dataset_name <- metadata$name
data_info[[1]]$display <- metadata$display
data_info[[1]]$source <- metadata$source
} else {
tables <- grep(".*\\.data\\.json$", data_urls, value = TRUE) %>%
lapply(\(x) jsonlite::fromJSON(x))
Expand Down