RStudio Connect does not seem to allow me to publish a parameterized RMarkdown that sources a script using the parameters. For example, I created the following test RMarkdown file:
---
title: "Parameter test"
params:
min_date: !r as.Date('2017-12-26')
output: html_document
---
knitr::opts_chunk$set(echo = TRUE)
source("test_script.R")
## R Markdown
Print the filtered dataframe:
```{r}
dates_filtered
which relies on this script, called test_script.R:
library(tidyverse)
dates <- data.frame(date_vec = seq(as.Date('2017-01-01'), as.Date('2017-12-31'), by = 'days'))
dates_filtered <- dates %>%
filter(date_vec >= params$min_date)
I can knit the Rmarkdown just fine locally, but when I attempt to publish, I get the error:
[Connect] 2020/07/16 20:16:59.279274519 Quitting from lines 13-14 (test_script.Rmd)
[Connect] 2020/07/16 20:16:59.315233580 Error: Problem with `filter()` input `..1`.
[Connect] 2020/07/16 20:16:59.315255817 ✖ object 'params' not found
[Connect] 2020/07/16 20:16:59.315288357 ℹ Input `..1` is `date_vec >= params$min_date`.
Any idea why Connect doesn't allow for this type of behavior, despite it working well locally?