callr is an R package that executes R functions in separate R processes, isolating computations from the current R session. It enables both synchronous and asynchronous process execution without affecting the parent process.
The package handles argument passing and return value copying between processes seamlessly, including error objects with full stack traces. It supports one-off function calls, persistent R sessions for repeated computations, and background processes that can be managed concurrently using polling. callr also provides interfaces for running R CMD commands and R scripts, with options to capture or redirect standard output and error streams.
Contributors#
Resources featuring callr#
Jacqueline Nolis | I made an entire e-commerce platform on Shiny | RStudio (2022)
E-commerce requires passing data between many components like managing a shopping cart, taking payment, fulfilling orders, and sending emails. I’ve successfully created a full e-commerce platform entirely in R for a quirky side project. The R package ggirl lets users order ggplot2 plots as postcards and more via R functions. Those R functions pass data to a separate Shiny app, which then passes data other services like Stripe payment APIs and printing APIs. In this talk I will walk through how to use packages like httr, callr, and brochure to have your Shiny apps call external services and do many tasks in parallel. You’ll leave the talk with more ways to use Shiny than dashboards plus the knowledge to monetize your existing dashboards!
Talk materials are available at https://link.jnolis.com/rstudio22-slides
Session: Unexpected uses of R
Veerle van Leemput | Analytic Health | Optimizing Shiny for enterprise-grade apps
Can you use Shiny in production? A: Yes, you definitely can.
Link to slides: https://github.com/RStudioEnterpriseMeetup/Presentations/blob/main/VeerlevanLeemput-OptimizingShiny-20220525.pdf
Packages mentioned: ⬢ shiny: https://shiny.rstudio.com/ ⬢ pins: https://pins.rstudio.com/ ⬢ plumber: https://www.rplumber.io/ ⬢ blastula: https://github.com/rstudio/blastula ⬢ callR: https://github.com/r-lib/callr ⬢ shinyloadtest: https://rstudio.github.io/shinyloadtest/ ⬢ shinycannon: https://github.com/rstudio/shinycannon ⬢ shinytest2: https://rstudio.github.io/shinytest2/ ⬢ feather: https://github.com/wesm/feather ⬢ shinipsum: https://github.com/ThinkR-open/shinipsum ⬢ bs4Dash: https://rinterface.github.io/bs4Dash/index.html
Timestamps: 2:44 - Start of presentation 5:41 - What qualifies as an enterprise-grade app? 10:46 - UI first / user experience / prototyping 13:20 - Separating code into separate scripts and creating code that’s easy to test 17:15 - Golem 19:28 - Functionize your code 20:50 - Rhino package, framework for developing enterprise-grade apps at speed 22:33 - Infrastructure, how do you bring this to your users? (lots of ways to do this. They do this with R, pins, plumber, rmd, blastula, and Posit Connect on Azure) 31:17 - Optimizing Shiny (process configuration, cache, callR, API, feather) 47:35 - Testing your app (shinyloadtest and shinycannon) 50:23 - Testing for outcomes (shinytest2) 52:15 - Monitor app performance & usage (blastula, shinycannon, usage metrics with Shiny app)
Questions: 57:38 - What’s the benefit of using pins rather than pulling the data from your database? 59:30 - Are there package license considerations you had to think about when monetizing shiny applications? 1:00:45 - Do you use promises to scale the application? (they use CallR) 1:01:49 - For beginners, golem or rhino? 1:02:50 - The myth is that only Python can be used for production apps, what made you choose to use R? 1:05:12 - Is feather strictly better than using JSON? 1:06:38 - Where do you see the line between BI (business intelligence) and Shiny for your applications? 1:08:36 - Any tips for enterprise-grade UI development? Making beautiful apps (bs4Dash app) 1:10:25 - Have you found an upper limit for users? 1:12:19 - Any tips for more dynamic data? (optimizing database helps here) 1:13:50 - Where do you install shinycannon? (on our development Linux server) 1:15:00 - Can you share other resources or examples of code? (Slides here with resources: https://github.com/RStudioEnterpriseMeetup/Presentations/blob/main/VeerlevanLeemput-OptimizingShiny-20220525.pdf )
For upcoming events: rstd.io/community-events-calendar Info on Posit Connect: https://www.rstudio.com/products/connect/ To chat with Posit: rstd.io/chat-with-rstudio
