curlconverter/curlconverter

[r] require-vs-library

r2evans opened this issue · 1 comments

The suggested R code starts with require(httr). While that may work, it is misusing the require function, as it can return FALSE (the package is not installed/available) but provide no error to the user. It is almost always better (especially in this type of use) to use library(httr) instead, as it will emit an error if the function is not available.

An alternative is

if (!require("httr")) {
  # do something here, perhaps
  install.packages("httr")
  library(httr)
}

Refs:

Thanks.

Thanks, I changed it to library(httr) in 07559b5 and 598d3c4 .