How to Write Production-Ready R Code: Tools and Patterns

By:
Marcin Dubel
June 25, 2020


<p style="text-align: center;"><em>This talk was presented virtually at eRum 2020 and useR 2020 by <a href="https://wordpress.appsilon.com">Appsilon</a> engineer Marcin Dubel. <a href="https://youtu.be/U1-j7c_8LFQ">Here</a> is a direct link to the video.</em></p>

<h3>Be Proud of Your Code!</h3>
In this talk you’ll learn the tools and best practices for making clean, reproducible R code in a working environment ready to be shared and productionized. I cover the benefits of <strong>git</strong>, <strong>plumber</strong>, <a href="https://appsilon.com/rstudio-connect-as-a-solution-for-remote-data-science-teams/"><strong>RStudio Connect</strong></a>, <strong>assertr</strong>, <strong>linter</strong>, <strong>renv</strong>, and many other tools and concepts.

R is a great tool for fast and efficient data analysis. Its simplicity in setup combined with powerful features and community support makes it a perfect language for many subject matter experts (e.g., in finance or bioinformatics). Nevertheless, what is often the case is that while the code provides a great solution, the application or model is not easily distributed to other team members or interested parties outside the team.

Both Appsilon and I personally have taken part in many R projects for which the goal was to clean and organize the code as well as the project structure. Data science teams working for our clients have all the expert knowledge and skills required to deliver value, but they are missing the programming experience required to provide mature, reproducible and production-quality code.

We would like to share our approach, best practices, and useful tools for creating high-quality R code that you can be proud to share.

During this presentation I will cover:
<ul><li>setting up the development environment with <strong>packrat</strong>, <strong>renv</strong>, and <strong>docker</strong></li><li>organizing the project structure</li><li>the best practices in writing R code, automated with <strong>l</strong><strong>inter</strong></li><li>sharing the code using <strong>git</strong></li><li>organizing workflow with <strong>drake</strong></li><li>optimizing the Shiny apps and data loading with <strong>plumber</strong> and <strong>database</strong></li><li>continuous integration with <strong>Github Actions</strong></li></ul>
If you have additional tools and suggestions to share for writing production-ready R code, please let us know in the comments!
<h3>Learn More</h3><ul><li>Want to learn how to create a computer vision model within an R environment? Watch Jędrzej Świeżewski's eRum/useR <a href="https://appsilon.com/fast-ai-in-r/">presentation on fast.ai in R</a>.</li><li>Video Tutorial: <a href="https://appsilon.com/video-tutorial-create-and-customize-a-simple-shiny-dashboard/">How to Create and Customize a Simple Shiny Dashboard</a></li><li>Find more Appsilon Data Science tutorials <a href="https://appsilon.com/tag/tutorials/">here</a>.</li></ul>
<strong>Does your company need help with enterprise data analytics or Shiny dashboards? Reach out to us at <a href="mailto:hello@wordpress.appsilon.com">hello@wordpress.appsilon.com</a>.</strong>

Have questions or insights?

Engage with experts, share ideas and take your data journey to the next level!

Is Your Software GxP Compliant?

Download a checklist designed for clinical managers in data departments to make sure that software meets requirements for FDA and EMA submissions.
Explore Possibilities

Share Your Data Goals with Us

From advanced analytics to platform development and pharma consulting, we craft solutions tailored to your needs.

Talk to our Experts
speed up shiny
r
data analytics
community
rstudio
tutorials