WARNING: rhino isnβt like the previous two frameworks weβve covered in this section, because rhino doesnβt create an app-package:
rhino apps rely on renv and box for managing imported dependencies (instead of the DESCRIPTION and NAMESPACE files in an R package).
rhino requires node.js, an open-source JavaScript runtime environment.
This chapter briefly describes a version of sap built using the rhino framework. The branch in this chapter is slightly different than the previous golem and leprechaun frameworks, because rap is not an R package. If youβre developing in RStudio , instead of loading, documenting, and installing rap, weβre going to re-initialize the IDE by selecting Session > Terminate Rβ¦
Re-initialize the IDE
When RStudio re-opens, we see the rap files and notice the Build pane has been removed:
rhino app IDE
To reiterate, the Build pane is deactivated because rhino applications arenβt R packages.1
Launch the application in rap by opening the app.R file and clicking Run App (or by passing rhino::app() into the Console).
As we can see, most of the standard R package folders and files are missing from rap, because rhino applications use the box package for importing dependencies and organizing code.2
25.2rhino features
The rhino website explains the philosophy behind the application structure above, so I wonβt repeat that information here. However, I highly recommend reading the available documentation on rhino and box before deciding to adopt this framework.3
25.3box modules
A box module (not to be confused with a Shiny module) is a collection of .R scripts in a specified folder. The modules in a new rhino app are stored in the app/logic/ and app/view/ folders:4
app/view/aes_inputs and app/view/var_inputs collect and return the reactive values from the UI. The app/view/display module includes the app/logic/data and app/logic/plot modules.
# app/view/display.R# import data and plot modulesbox::use( app / logic / data, app / logic / plot)
25.4app/main.R
The app/main.R file contains the primary UI and Server functions for the application. This file adds the shiny functions and the aes_inputs, var_inputs, and display modules from app/view:
Below is the boilerplate test code in the tests/testthat/test-main.R file:
box::use( shiny[testServer], testthat[...],)box::use( app/main[...],)test_that("main server works", {testServer(server, {expect_equal(output$message, "Hello!") })})
1
box module importing test package functions
2
Using shiny::testServer() and testthat::test_that() functions in test.
Iβve included tests for the utility functions and modules in the 25_rhino branch, but Iβll cover testing with rhino elsewhere.5
25.6rhino dependencies
In rhino apps, dependencies are managed by renv and the dependencies.R file. The renv package is designed to,
βcreate[s] and manage[s] project-local R libraries, save[s] the state of these libraries to a βlockfileβ, and later restore[s] the library as required.β6
The rhino::pkg_install() helper function updates both the dependencies.R file and renv library. Using dependencies.R, renv, and box modules removes the need to manage dependencies in a DESCRIPTION or NAMESPACE file.7
Recap
RECAP β
rhino takes a novel and innovative approach to developing Shiny applications (and covering all the ways they differ from app-packages is beyond the scope of this book). Feel free to review the code in the 25_rhino branch for a better understanding of how the box modules are structured and used within the ui and server.
The rhino framework isnβt used as wildly golem,8 but itβs been gaining popularity (and has been used in a recent pilot FDA submission).