Sometimes I need to download data from the internet. On occasions this has failed either because the website is down or because my computer has lost its internet connection.
This is a version of eyjo's answer which sacrifices accuracy for speed.
IPavailable <- function() { cmd <- switch(.Platform$OS.type, "windows" = "ipconfig", "ifconfig") any(grep("(\\d+(\\.|$)){4}", system(cmd, intern = TRUE))) }