Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic R Markdown template demonstrating saved variants and custom email generation with RStudio Connect
---
title: "Variants with Different Schedules"
output: html_document
params:
engineer:
label: "On-call Engineer:"
value: Kelly
input: select
choices: [Cole, Kris, Kelly, Sean]
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Parameterized R Markdown: Rotation Emailer
Send a reminder email to the on-call engineer and the on-deck engineer, reminding them what their responsibilities are for the week.
```{r message=FALSE}
library(tibble)
library(dplyr)
# Create a rotation
rotation <- tribble(
~oncall, ~ondeck,
"Cole", "Kris",
"Kris", "Kelly",
"Kelly", "Sean",
"Sean", "Cole"
)
# Use the 'engineer' parameter to look up the on-deck engineer
thisweek <- rotation %>%
filter(oncall == params$engineer)
nextup <- thisweek$ondeck
```
### This Week:
- **Engineer On Call:** `r params$engineer`
- Engineer On Deck: `r thisweek$ondeck`
```{r}
library(blastula)
# Link to published banner created in Google Drive
img_link <- "https://docs.google.com/drawings/d/e/2PACX-1vTA_XbfXQ2Ms90lqrrHVYf7ugeS42Gd1JpTc5VFodiy6t0RqOXUzvySdlx3zSwD5ZmGDIXsMetA-DM6/pub?w=480&h=124"
message <- compose_email(
body = "
Hi {params$engineer},
This is an automated notice reminding you that you'll be on-call this week!
![Cute Reminder Image]({img_link})
Remember to schedule a meeting with {thisweek$ondeck} \\
on Friday to transition any carry-over tasks for next week.
<br />
Cheers, <br />
Solutions Engineering Reminder-Bot"
)
# Set the R Markdown Output Metadata for email body and images
rmarkdown::output_metadata$set(rsc_email_body_html = message$html_str)
rmarkdown::output_metadata$set(rsc_email_images = message$images)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment