This tries to attach a package if you have it; if not, it tries to install it from BioConductor or CRAN; if not available there, it tries to install it from the cran mirror on GitHub, which includes packages that have been removed from CRAN; if not available there, it looks for a matching other package on GitHub to install. Note this is sloppy practice and prone to all sorts of risks. However, there are use cases, such as quick scripting, or in a class where students already know best practices, where this can be useful. yearn was inspired by teaching in PhyloMeth, a course funded by an NSF CAREER award to the author (NSF DEB-1453424).
Sometimes you just yearn for a package you need to use. You feel guilty about this, but just want to load it with
library() and have it just work -- and if you don't have the package installed already, simply have the script install it first without having to figure out if it's on CRAN, Bioconductor, or GitHub, etc. If you're in this sort of mood, you probably don't care about case: is it
phangoRn -- you might even be willing to tolerate a letter or two off (though not by default).
This is sloppy. You should know what packages you need, install them, consider keeping track of versions with packrat or similar. But for a quick and dirty analysis, or when facing a classroom of angry students who are trying to pull in packages for a class exercise, this can be handy ("Download these from CRAN; go to Bioconductor for this; then get this new package that's only on GitHub -- no, it's
install.github(), but, yeah,
install.packages() -- wait, where are you going, class?"). So, to do this,
And then call a package you want with just
pkgdown is just an example of a potential package (one used to create the
yearn package webpage, in fact). Note that currently the package name should be a bare string, not in quotes. Another option, once
yearn has been installed, is to use the
yearn::yearn(pkgdown) without having to do the library call first.
The package goes through a standard procedure when you do this:
require(). If it works, it's done.
yearn(), it will allow up to that many spelling mismatches. By default this is zero. If it finds a match, it installs it, then tries to load it.
?yearn. If you're using this to teach a class using your software, you might want to add your user name to the list.
This package uses some key functions from the githubinstall package on CRAN, written by Koji Makiyama, Atsushi Hayakawa, Shinya Uryu, Hiroaki Yutani, and Nagi Teramo. However, it also incorporates checking CRAN and Bioconductor first, and it does not offer the interactivity of the
githubinstall package in cases of multiple matches (it also is pickier about spelling mismatches than
githubinstall by default).
Again, use at your own risk. This package is chatty about potential problems and where it's downloading packages, but it could be that you're loading a package that has the same name of what you want but does something different, someone could have done something malicious with a package they put on GitHub, etc.
Work on this was partially funded by NSF CAREER award 1453424 to Brian O'Meara (the package is useful for the class I teach as part of that award).