0

I'm creating an R package, and I would like to rely on the falsy package, which has recently been archived from CRAN.

With a non-archived package, one would typically add the name of the package to the Imports list in the DESCRIPTION file. How does one import a package that's been archived by CRAN?

Note: After contacting Gábor it seems the reason falsy is archived is due to potentially dangerous inconsistencies between native and falsy notions of falsehood. He does not plan to unarchive the package.

Thomas
  • 43,637
  • 12
  • 109
  • 140
user12341234
  • 6,573
  • 6
  • 23
  • 48
  • [This](http://stackoverflow.com/a/32533483/324364) might be the answer you're looking for...? – joran Sep 22 '16 at 15:31
  • That's definitely A solution, though an ideal solution wouldn't require any action on the part of the end user. – user12341234 Sep 22 '16 at 15:36
  • The comments on that question also discuss the option of creating your own **drat** repo on github, which might be more work for you, but probably less for users. – joran Sep 22 '16 at 15:39
  • I see two options: 1) copy the source code for the functions you need from `falsy` into your own package. Then provide proper attribution to the author of those functions. 2) Send a request to CRAN to become the package maintainer for `falsy`, fix the check problems, and resubmit it to CRAN. – Benjamin Sep 22 '16 at 15:41
  • Re 2) It appears that falsy has already been patched to pass tests: https://github.com/gaborcsardi/falsy/commit/ee26873d99255560cfad60be2812cea4437d20e1 . It's getting 0 errors/warnings/notes from check() on my machine with R 3.3.1. – user12341234 Sep 22 '16 at 15:44

1 Answers1

0

This:

FALSY <- FALSE

TRUTHY <- TRUE

is_falsy <- function(object) {
  is.null(object) ||
    identical(object, FALSE) ||
    identical(object, 0L) ||
    identical(object, 0.0) ||
    identical(object, 0+0i) ||
    identical(object, "") ||
    identical(object, as.raw(0)) ||
    identical(object, logical()) ||
    identical(object, integer()) ||
    identical(object, double()) ||
    identical(object, complex()) ||
    identical(object, character()) ||
    identical(object, raw()) ||
    identical(object, list()) ||
    inherits(object, "try-error")
}

is_truthy <- function(object) {
  ! is_falsy(object)
}

`%&&%` <- function(lhs, rhs) {
  lres <- withVisible(eval(lhs, envir = parent.frame()))
  if (is_truthy(lres$value)) {
    eval(rhs, envir = parent.frame())
  } else {
    if (lres$visible) { lres$value } else { invisible(lres$value) }
  }
}

nay <- function(rhs) {
  if (is_falsy(rhs)) { TRUTHY } else { FALSY }
}

try_quietly <- function(expr) {
  try(expr, silent = TRUE)
}

is the entire extent (minus roxygen comments) of the package. Why not just include it in your package?

Failing that, possibly ask Gabor if he's planning re-releasing it to CRAN or if you could take over maintenance?

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
  • I've contacted Gabor, waiting on a reply. I'm hesitant to copy the source directly because I believe code duplication is inherently bad. – user12341234 Sep 22 '16 at 17:24
  • It's **significantly** better than relying on an archived package. – hrbrmstr Sep 22 '16 at 17:25
  • Interesting. What are your reasons for saying that? – user12341234 Sep 22 '16 at 22:30
  • 1
    Because the average R user will have no idea how to install it and it got archived for a reason (usually due to it failing CRAN checks). Why would you rely on something like that? Seems crazy to me and pretty disrespectful of your potential user base. – hrbrmstr Sep 22 '16 at 23:00