Skip to content

Instantly share code, notes, and snippets.

@javierluraschi
Last active August 9, 2018 01:10
Show Gist options
  • Save javierluraschi/f257b1f91b255e23a6f845a9c45fe5ae to your computer and use it in GitHub Desktop.
Save javierluraschi/f257b1f91b255e23a6f845a9c45fe5ae to your computer and use it in GitHub Desktop.
RStudio 1.2: Package Improvements
RStudio 1.2 comes with improvements to manage **package repos** and adds better support to packages that provide **testing infrastructure** and **database connectivity**.
## Package Repos
Some organizations set up private CRAN repos to share internal packages, one way of accomplishing this is by
creating a private CRAN repos as described in the [R Admin Guide](https://cran.r-project.org/doc/manuals/R-admin.html#Setting-up-a-package-repository). Other projects rely on `drat` to provide CRAN-compatible repos. With RStudio 1.2 you can easily configure and prioritize: private, primary or secondary CRAN repos through the preferences pane. For instance, at the
time of this writting, the `limer` package from the `cloudyr` project was not available on CRAN; however, the `cloudyR`
project provides a `drat` repo `http://cloudyr.github.io/drat` that we can easily add as a secondary repo:
`IMAGE`
and install `limer` with ease from he `Packages` pane. Additionally, you can open the package in the primary repo directly from the packages pane:
`IMAGE`
This feature is also compatible with [RStudio's Package Manager](https://www.rstudio.com/products/package-manager/), which
can act as a private CRAN repo and help your organization manage all your packages with ease.
## Test Packages
For those of you that have developed R packages, you'll be familiar with [testthat](), a package that brings the power
of unit testing and testing in general to R. With RStudio 1.2 you can now run a single `testthat` test directly from
the test source:
`IMAGE`
and also see all the test failures and warnigns in the build pane:
`IMAGE`
For those working with Shiny applications, the [shinytest]() package allows you to record and run Shiny tests with ease.
RStudio 1.2 adds entry points to record and run tests from your souce files:
`IMAGE`
and to explore the test results from a new "Test Results" tab:
`IMAGE`
## Database Packages
When working with databases, you'll often find yourself using the [DBI](), [ODBC]() and [keyring]() packages.
`DBI` provides support to execute arbitrary SQL statements, which now you can get started directly from the files menu:
`IMAGE`
and preview it's results when sourcing `SQL` files:
`IMAGE`
When running SQL through ODBC drivers using the `odbc` package, you usually have to install ODBC drivers
in your system first. We made this a bit easier by adding support to custom ODBC driver installers.
Anyone can make a driver installer for their favourite ODBC driver, see [extending ODBC installers]() article.
For those using RStudio Desktop PRO, we made installers available to all the RStudio PRO Drivers:
`IMAGE`
Finally, but not least! When connecting to databases and remote services in general, it's recommended to store
your credentials securely. For instance, using the `keyring` package which provides cross-platform support to
store such secrets securely. RStudio 1.2 adds a new `rstudioapi::askForSecret()` function, which can be used to
invoke a new secure prompt that records and retrieves secrets securely using `keyring`:
`IMAGE`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment