csgillespie / efficientR

Efficient R programming: a book
https://csgillespie.github.io/efficientR/
Other
721 stars 375 forks source link

Update data carpentry section #262

Open Robinlovelace opened 4 years ago

Robinlovelace commented 4 years ago
csgillespie commented 4 years ago

Initial thoughts:


Broken URLs

files = list.files(".", pattern = "*.Rmd")
urls = suppressWarnings(system2("grep", c("-Eo \"(http|https)://[a-zA-Z0-9\\.\\+:/?=_-]*\"", 
                                          files[5]), stdout = TRUE))

for (url in urls) {
  ping = try(httr::GET(url), silent = TRUE)
  if (class(ping) == "try-error") {
    cli::cat_bullet(glue::glue("{url}: {ping}"))
  } else if (ping$status != 200) {
    cli::cat_bullet(glue::glue("{url}: {ping$status}"))
  }
}