R reports schedule

Can I schedule the R reports scheduled via RS Connect on the first business day of the month? I know RS connect probably doesn't have the capability but is it possible to take care of the schedule within the rmd?

Thanks for the question!

You are correct that RStudio Connect does not have the built-in capability to be able to specify the first weekday of the month in a schedule. I can pass along your feedback to the product team. Rather, Connect has the ability to schedule a report in terms of the n-th specific weekday of the month.

However, you could use the Connect feature for Suppressing Scheduled Email to achieve what you want by using code in your R Markdown report.

For example, define the following in the YAML header:

title: "Report Title"
  rsc_email_suppress_scheduled: true

Then, schedule the report to run daily and add the following code to your report:

isFirstWeekday <- compute_first_weekday()

if (isTRUE(isFirstWeekday)) {
  # Send email if it is the first weekday of the month
  rmarkdown::output_metadata$set(rsc_email_suppress_scheduled = FALSE)

Which will result in Connect running the report once per day, but only sending email if the computed value for isFirstWeekday is true.

I'll leave it to you to develop the compute_first_weekday() function to determine if the current day is the first weekday of the month. :smile: The lubridate package would be a good help here.



Thank you for the reply. That is exactly what I was looking for as a workaround. Though it would be great to see as it as an option in RS Connect which will be much economical I guess. Thanks again.