Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We are pleased to announce that Rhino 1.4 is now available on CRAN! This update simplifies dependency management in your project, allows you to integrate React seamlessly into your app, and resolves some issues with {box} modules. Read on to learn more!
Simplified Dependency Management
Rhino relies on {renv} for managing R package dependencies in your project. Our setup ensures that your dependencies are:
- Explicit: Your direct dependencies must be listed in the dependencies.R file.
- Reproducible: The lockfile saves the exact package versions and sources of all your direct and transitive dependencies.
- Isolated: Your project has its own library, separate from packages installed in other projects or globally.
While these benefits are valuable, they come with some associated costs. Until now, you had to handle the bookkeeping manually. Adding or removing dependencies required three separate steps: updating dependencies.R, the lockfile, and the library.
Rhino 1.4 introduces two new functions: pkg_install()
and pkg_remove()
. These functions allow you to install a new package, update one to the latest version, or remove a package from your project – all in one step.
For quick examples, refer to the function reference. If you’re interested in understanding the inner workings of our setup, we encourage you to explore our Explanation: Renv Configuration.
Support for React
React is a widely popular JavaScript library for building web interfaces, and we have invested significant effort to make it possible to use React and its associated UI toolkits in Shiny.
Our work so far includes:
- {shiny.fluent}, a wrapper for Fluent UI, a UI toolkit from Microsoft.
- {shiny.blueprint}, a wrapper for Blueprint, a UI toolkit from Palantir.
- {shiny.gosling}, a wrapper for Gosling, a toolkit for genomics data visualization.
- {shiny.molstar}, a wrapper for Mol*, a toolkit for molecular data visualization.
All of this has been made possible through our {shiny.react} package, which provides the necessary functionality to seamlessly integrate React with Shiny. However, up until now, its use was limited to creating R package wrappers for JavaScript libraries.
With Rhino 1.4, you can now define React components directly in your application and effortlessly integrate them into your R code. After adding shiny.react to your project, you can achieve this in three simple steps:
- Define the component using JSX, a syntax extension for JavaScript.
- Declare the component in R.
- Use the component in your application.
For detailed instructions, refer to our Tutorial: Use React in Rhino.
Improved Box Modules
Encapsulation and modularization are at the core of Rhino’s philosophy. To provide you with a modern import system, we rely on the {box} package, which offers features such as custom file and directory structure for your code, explicit import/export statements, module caching, and more.
With Rhino 1.4, we now require box v1.3.1 or later, as it addresses some issues present in earlier versions. The improvements include:
- Lazy-loaded data: You can now import data in the same way as other objects, using syntax like box::use(rhino[rhinos]), without the need for rhino::rhinos.
- Trailing commas: Trailing commas will no longer cause issues when using reexports or when calling functions accessed via $.
To gain a deeper understanding of {box} in the context of Rhino, we invite you to explore our Explanation: Box Modules.
Thorough Verification
Testing a package like Rhino poses challenges due to its nature, as it heavily relies on system tools, specific project structure, and requires network and filesystem access. Writing unit tests for many parts of the codebase can be impractical.
However, ensuring the correctness of our package and performing proper verification are of utmost importance to us. To address this, we now employ comprehensive end-to-end tests internally. These tests automatically verify all functionalities of Rhino, providing us with the confidence we need in the package’s reliability.
How to get Rhino 1.4?
To begin a new project with Rhino 1.4, simply run install.packages("rhino")
to install the latest version from CRAN. If you already have an existing Rhino project, you can update it by following these steps:
- Run
renv::update("rhino")
to update the Rhino package. - Run
renv::snapshot()
to update the lockfile.
The post appeared first on appsilon.com/blog/.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.