knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

{linkrot}

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept. R-CMD-check Codecov test coverage rostrum.blog
post

An R package to help detect linkrot, which is when links to a web page break because they've been taken down or moved.

Very much a concept. I wrote it to detect linkrot on my personal blog and it works for my needs. Feel free to contribute.

Install

This package is only available on GitHub. Install from an R session with:

install.packages("remotes")
remotes::install_github("matt-dray/linkrot")

Example

Pass a webpage URL to detect_rot() and get a tibble with each link on that page and what its response status code is (ideally we want 200).

Here's a check on one of my older blog posts. The printout tells you the URL you're looking at, with a period printed for each successful check.

library(linkrot)
page <-  "https://www.rostrum.blog/2018/04/14/r-trek-exploring-stardates/"
rot_page <- detect_rot(page)
rot_page

Uh oh, at least one is broken: it has a response_code of 404.

You could iterate over multiple pages with {purrr}:

pages <- c(
  "https://www.rostrum.blog/2018/04/14/r-trek-exploring-stardates/",
  "https://www.rostrum.blog/2018/04/27/two-dogs-in-toilet-elderly-lady-involved/",
  "https://www.rostrum.blog/2018/05/19/pokeballs-in-super-smash-bros/"
)

library(purrr)
rot_pages <- set_names(map(pages, detect_rot), basename(pages))
rot_pages

Uh-oh, more broken links.

Code of Conduct

Please note that the {linkrot} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



matt-dray/linkrot documentation built on Dec. 21, 2021, 2:54 p.m.