Resources

Caroline Ledbetter | Rproject templates to automate and standardize your workflow | RStudio (2020)

Many teams and organizations have tasks and structures that are standard across projects. Lack of consistency and documentation can lead to lost productivity when team members join collaborations or previous work is consulted by your future self. Setting up folder structures can be particularly tedious. This talk will demonstrate using Rstudio project templates as part of an organizational package to automatically setup file structures, establish git repositories and add standardized readme files. It will also show how including report templates for Rmarkdown files can lead to more consistent and professional reports. Project info can be optionally stored so that project information can be easily added automatically to the top of reports and included in snippets for code file headers. Creating standard, easy to implement documentation and procedures can be particularly effective in encouraging skeptical collaborators to use git and Rmarkdown. Organizational packages can also be a great place to house functions that are specific and common to an organizations needs. The talk will showcase this functionality using the CIDAtools package that we developed. While the CIDAtools package was developed to address issues that sometimes arise from the less structured environment of academia, the tools presented can be equally useful in an industry setting. A 5-minute presentation in our Lightning Talks series

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Hi, so my name is Caroline Ledbetter and I'm going to speak to you about how incorporating the Rproject templates can help you standardize and automate your workflow.

Why Rproject templates?

So why Rproject templates? If you can automate something, you should automate something. Things are that you, when you do Rprojects, you tend to either you as a person or as your organization has a standardized file structure, readmes that you like to put into it, maybe you always set it up as a GitHub repo, all of these things that are probably unique to your workflow or your organization. You can set this up to do that automatically for you every time.

If you can automate something, you should automate something.

And if you are an organization and you set this up, it ensures that everybody is following the same stuff, which helps you in the future.

What you need to set up Rproject templates

So what do you need to set up your own Rproject templates? You need an Rproject. They have to live in an Rproject. This can be just a simple internal project. It can live on GitHub. It can live wherever your Rprojects live. You need a template metadata file and a template function file, and I'm going to show you using our internal CetaTools package what those look like.

So I've highlighted them here. So your project setup DCF is your template metadata, and newproject.R is our template function, and I'm going to demonstrate how we as an organization use this functionality in ours. So we have the CetaTools package. All of the code is available on GitHub. So after this talk, if you want to see exactly all of these steps, you can see it there.

The CetaTools package in practice

So for us, we do a lot of scientific research with an academic center. So we have principal investigators. We have analysts. We have a GitLab internal server where we usually store our stuff in Git. So you can put all of this information in here, and some of it is optionally stored in a DCF file so that it can be referenced in headers and in snippets, and so you don't have to keep putting that information for each project in, and it also gives you this choice of getting your repo started.

And so this is just an example of what the template metadata looks like. It uses widgets that are very similar to Shiny, if you're familiar with that, but you can see right here, you know, from the previous screen, we had the principal investigator option. It does not have a default. You can decide where it goes and in what order and what its label is and stuff like that, and what kind of input it is.

And then this is our project setup function, just to give you an idea of what that looks like. So all of those parameters that you set up in the previous screen are passed through the dots argument, so you access them just like you would access other dots arguments through a function.

And RStudio has a fantastic how-to guide of how to set these up. The website is there. If you want to check out our repo and see exactly how our stuff is laid out and how that might apply to the way you'd like to set up your R project templates, the repo is leadbettscetatools. And then the slides for this will be up on my website probably tomorrow. You can reach me at carolineledbetter at yahoo.com, and you can find me on GitHub and Twitter. Thank you.