background preloader

Packages

Facebook Twitter

Library() vs require() in R. While I was sitting in a conference room at UseR!

library() vs require() in R

2014, I started counting the number of times that require() was used in the presentations, and would rant about it after I counted to ten. With drums rolling, David won this little award (sorry, I did not really mean this to you). After I tweeted about it, some useRs seemed to be unhappy and asked me why. Loading R Packages: library() or require()? When I was an R newbie, I was taught to load packages by using the command library(package).

Loading R Packages: library() or require()?

In my Linear Models class, the instructor likes to use require(package). This made me wonder, are the commands interchangeable? What’s the difference, and which command should I use? Interchangeable commands . . . The way most users will use these commands, most of the time, they are actually interchangeable. CRAN logs. Analyzing Metadata for CRAN Packages · R Views.

By Joseph Rickert I have been searching for various ways to find information about R packages for some time now, but I only recently learned about the CRAN_package_db() function in the base tools package.

Analyzing Metadata for CRAN Packages · R Views

If a colleague hadn’t pointed it out to me, I am sure I would never have found it on my own. Changing R default library path using .libPaths in Rprofile.site fails to work.

See the comment about setting an environment variable in Windows – alanyeung

Playing around with RStudio Package Manager. Managing packages in production is a lot of work: you have to juggle between versions, internal packages, CRAN updates, Bioconductor, GitHub sources… Let’s have a look into RStudio Package Manager, one of the tools available that helps you dealing with this.

Playing around with RStudio Package Manager

What is love RSPM (Baby don’t hurt me, no more RStudio Package Manager (or RSPM for short) is a solution designed to help you to deal with the installation of packages in your organisation. Wether you need to make available to your team the whole CRAN through a proxy, a selection of the CRAN, GitHub packages, internal packages, etc, you can use RSPM as a central point for managing that. It can also be useful if you have an network connection which is handled through a proxy, as RPSM can be configured to work with a proxy. Searching for R Packages. By Joseph Rickert Searching for R packages is a vexing problem for both new and experienced R users.

Searching for R Packages

With over 13,000 packages already on CRAN, and new packages arriving at a rate of almost 200 per month, it is impossible to keep up. Package names can be almost anything, and they are rarely informative, so searching by name is of little help. 'packagefinder' - Search for packages from the R console. There are over 12,700 R packages on CRAN.

'packagefinder' - Search for packages from the R console

How to find the right one for you? The new package 'packagefinder' helps you search for packages on CRAN right from the R console. With 'packagefinder' you can search for multiple keywords in the name, title and description of the CRAN package, either case-sensitive or insensitive and define your own weighting scheme for the search results, if you like. Once you have found a promising package, you can use the simple function go() to go to the package's CRAN webpage or view its PDF manual, directly from the R console without having to installing the package first. Of course, you can also install the package easily, if you want to try it out. CRANalerts - Get email alerts when a CRAN package gets updated.

How many R packages at CRAN are associated to your University? Offline install of R package and dependencies. How do I install an R package from source. Install a package from Github as a zip file.

Devtools::install_local() is simpler – alanyeung

Installing Package Dependencies without external http(s) requests. Speeding up package installation. Can’t be bothered reading, tell me now.

Speeding up package installation

Faster R package installation. Faster package installation Every few weeks or so, a tweet pops up asking about how to speed up package installation in R Depending on the luck of twitter, the author may get a few suggestions.

Faster R package installation

The bigger picture is that package installation time is starting to become more of an issue for a number of reasons. For example, packages are getting larger and more complex (tidyverse and friends), so installation just takes longer. Or we are using more continuous integration strategies such as Travis or GitLab-CI, and want quick feedback. Quick Way of Installing all your old R libraries on a New Device. I recently bought a new laptop and began installing essential software all over again, including R of course!

Quick Way of Installing all your old R libraries on a New Device

And I wanted all the libraries that I had installed in my previous laptop. Instead of installing libraries one by one all over again, I did the following: Step 1: Save a list of packages installed in your old computing device (from your old device). installed <- as.data.frame(installed.packages()) write.csv(installed, 'installed_previously.csv') This saves information on installed packages in a csv file named installed_previously.csv. Reinstalling packages on new version of R. Pak: Another Approach to Package Installation. The Whole Game. Spoiler alert!

The Whole Game

This chapter runs through the development of a small toy package. It’s meant to paint the Big Picture and suggest a workflow, before we descend into the detailed treatment of the key components of an R package. To keep the pace brisk, we exploit the modern conveniences in the devtools package and the RStudio IDE. Writing Frictionless R Package Wrappers. Package Development in R. Usethis 1.3.0 - Tidyverse. We are pleased to announce that usethis 1.3.0 is now available on CRAN. usethis automates many common setup tasks for R projects, especially, but not only, for R packages. You can learn more about it at Install it with: install.packages("usethis") usethis is part of the refactoring of the devtools package. Getting Down with pkgdown. Pkgdown is an incredibly powerful tool for building beautiful websites for R packages. With pkgdown and services like GitHub Pages, deploying a package website is so simple and straightforward that I’m starting to see it as an essential part of writing a package.

What’s more, I’ve found that the act of preparing a package website has led me to improve the package itself, particularly the readability and usefulness of its documentation. I say “incredibly” powerful in the most literal sense—I could not believe how much pkgdown does with so little required of its user. pkgdown draws its power by relying on conventions of how R packages are structured.

Some of these conventions are inherent to R packages, particularly what CRAN deems as acceptable. Others, however, are less obvious. This post distills my experiences in setting up a few pkgdown sites recently and exposes some of the features of pkgdown that I discovered along the way. Generally, you won’t want to stop here. Edit man pages. Automating roxygen2 package documentation.

Spelling 1.0: quick and effective spell checking in R. The new rOpenSci spelling package provides utilities for spell checking common document formats including latex, markdown, manual pages, and DESCRIPTION files. Publishing an R package in the Journal of Statistical Software. I’ve been an edi­tor of JSS for the last few years, and as a result I tend to get email from peo­ple ask­ing me about pub­lish­ing papers describ­ing R pack­ages in JSS.

So for all those won­der­ing, here are some gen­eral comments. JSS prefers to pub­lish papers about pack­ages where the pack­age is on CRAN and has been there long enough to have matured (i.e., obvi­ous bugs ironed out and a few active users). This is partly because we have so many sub­mis­sions that it helps to fil­ter some out and this approach pro­vides some basic qual­ity checks. So I sug­gest you begin by devel­op­ing the pack­age for CRAN. This is a pref­er­ence rather than a require­ment, and it is not stated any­where in the JSS rules. We pre­fer sub­stan­tial pack­ages rather than very spe­cific but small pack­ages. This paper/​package does what it claims quite well, but it could do so much more. JSS papers involve a review of the soft­ware as well as the paper.

R Package Development Pictorial. An R package is a nice tidy way to reuse and share functions you have created. In my experience, most packages fall into one of three categories: Packages that have some specific topical function: This would include packages like readXL or scrapeR that are designed with a number of functions to do one sort of thing (read in files and scrape files off the web respectively). These kinds of packages also often accompany publications about new statistical techniques and provide a way for other people to use the method. Almost always available on CRAN.Utility Packages: These packages might do lots of general stuff like igraph or MCMCpack which provide lots of utility functions for dealing with networks and MCMC inference respectively.

How to develop good R packages (for open science) Drat Basics for Package Users: Installing or Updating Packages. It depends - A dialog about dependencies. Depends, Imports, Suggests. Including Optional Functionality from Other Packages in Your Code. Let’s say you want to write a function with optional functionality which is dependent on the installation of a package that your colleague may not have installed. For example, let’s say you want to have an option to return a data.table (or a tibble) instead of a data.frame, but in this case you don’t want to force your function’s user to have to install data.table (or tibble - and its dependencies) just to use your function.

Maybe they can’t install it because they are restricted to do so by their IT department or maybe they are working offline. Writing an R package from scratch. Usethis workflow for package development. This code have been lightly revised to make sure it works as of 2018-12-20. {attachment} is on CRAN. HexSticker: Hexagon sticker in R. Goodpractice package. Hardhat 0.1.0. Internal functions in R packages. Code examples in the R package manuals. Workflow automation tools for package developers.

As a package developer, there are quite a few things you need to stay on top on. Following bug reports and feature requests of course, but also regularly testing your package, ensuring the docs are up-to-date and typo-free… Some of these things you might do without even pausing to think, whereas for others you might need more reminders. Communicate lifecycle changes in your functions. Releasing a package · R packages. Win-builder.R-project.org. R-hub builder. Rhub and WinBuilder. R-hub: why R package developers should care.

R-hub Docs. Checking CRAN incoming feasibility ... NOTE Maintainer. Checklist for R package submission to CRAN. Use_release_issue() automatically generates a checklist of tasks to do during the submission process.