0

My question is about package YieldCurve of R.

The R YieldCurve package used for modeling yield curves with parametric models like Nelson Siegel and Svensson has been removed from rcran, so it is not possible to download it in RStudio.

Is there a way to load it from another repository?

Is there a package that replaces it and allows to do the same thing that YieldCurve did?

  • Does this answer your question? [How do I install an R package from source?](https://stackoverflow.com/questions/1474081/how-do-i-install-an-r-package-from-source) – Marijn Aug 03 '22 at 15:11
  • The package can be downloaded from https://cran.r-project.org/src/contrib/Archive/YieldCurve/, see for example https://stackoverflow.com/a/26500661/ for an easy way to install archived packages. – Marijn Aug 03 '22 at 15:13

1 Answers1

2

Especially if packages are recently archived, they can usually be installed from source without a problem.

I've been meaning to write this helper function for a little while:

  • go to CRAN archive page for the package
  • find the most recent/last version of the package (I'm not sure this will work perfectly if the package versions are such that they are sorted inconsistently in alphabetical order ...)
  • construct the location of the 'tarball' (compressed source archive)
  • install

If the package has compiled components you'll need to have development tools installed.

This is very much like remotes::install_version() but (1) it finds the latest archived version automatically (2) you don't need to install the remotes package.

install_last_archived <- function(pkg, verbose = TRUE) {
    arch_url <- "https://cran.r-project.org/src/contrib/Archive/"
    rr <- readLines(paste0(arch_url, pkg))
    last <- tail(rr[grepl(pkg,rr)],1)
    tarball <- gsub(sprintf(".*(%s_[0-9.]*\\.tar\\.gz).*", pkg), "\\1", last)
    if (verbose) cat("installing ", tarball, "\n")
    install.packages(paste0(arch_url, pkg, "/", tarball), repos = NULL)
}

install_last_archived("YieldCurve")

Possible enhancements: (1) work harder to make sure we have the most recent version (check dates explicitly?) (2) extract the DESCRIPTION file to see if the package has compiled components, if so then warn user ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453