I have a function in a R Markdown document. The function takes a "case number" variable, which is used to filter some data frames, produce a plot, and output the plot to a knit html document. Here's the basic idea:
#Outside of function, I have my unfiltered dataset:
as.data.frame(my.dataset)
build_plots <- function(unique_case_id) {
my.dataset.filtered <- my.dataset %>%
filter(case_id==unique_case_id)
#draw plot
data <- as.data.frame(my.dataset.filtered)
p <- vistime(data)
pb <- plotly_build(p)
pb #display plot
# Output plot to html doc
rmarkdown::render(input = "myFile.Rmd",
output_format = "html_document",
output_file = 'myFile.html',
output_dir = "//myDir/myFolder")
}
build_plots("1234")
This seems to just process the file on an infinite loop:
processing file: myFile.Rmd
processing file:myFile.Rmd
And produces a blank output in the html doc, with no plot.