Jan Pips
Jan Pips

Reputation: 145

How to render directly to html rmd file that contains knit_expand

I have two Rmd files

main.Rmd

---
title: "Report"
author: "User"
output:
    flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---


```{r setup, include=FALSE}
library(flexdashboard)
library(highcharter)
library(htmlwidgets)
library(lubridate)
library(knitr)
```


```{r run-numeric-md, include=FALSE}
warehouse <- data.frame("id" = c("WARE-01", "WARE-02", "WARE-03"))
warehouse$group <- c("1", "2", "3")
out = NULL
for (row in 1:nrow(warehouse))
    {
        out = c(out, knit_expand
            (
                'template.Rmd', 
                warehouse_id = warehouse[row, "id"],
                warehouse_group = warehouse[row, "group"]
            )
        )
    }
```


`r paste(knit(text = out), collapse = '\n')`

and template.Rmd used for knit_expand command

Sales revenue net / {{warehouse_id}} {data-navmenu={{warehouse_group}}}
=====================================

Column {data-width=500}
-------------------------------------
### {data-height=100}

```{r}
valueBox("Sales revenue net",
         caption = paste("Item UPC:<b>", "</b> :: Contractor ID:<b>", "</b> :: Warehouse ID:<b>","{{warehouse_id}}" ,"</b>"))
```

### {data-height=900}



Column {data-width=500}
-------------------------------------

### {data-height=500}

### {data-height=500}

Executing knit to flex_dashboard from menu I am able to produce required output. I would like however to execute the main.rmd from r script file using

rmarkdown::render(
    input = "main.Rmd", 
    output_file = "main.html",
    output_format = "all")

However when I execute r code (above) I am getting error

Error in do.call(output_format_func, options) : second argument must be a list

Any ideas what I am doing wrong?

Upvotes: 0

Views: 1693

Answers (1)

shosaco
shosaco

Reputation: 6165

Either use output_format = "flex_dashboard" or add the argument output_options=list(), so that he gets his expected options list :)

rmarkdown::render(
    input = "main.rmd", 
    output_file = "main.html",
    output_format = "all", output_options = list())

or

rmarkdown::render(
    input = "main.rmd", 
    output_file = "main.html",
    output_format = "flex_dashboard")

Upvotes: 2

Related Questions