将markdown文件呈现为有光泽的html。

时间:2022-05-04 06:19:06

My render function to create the html file from the rmd file is as follows:

我的渲染函数从rmd文件创建html文件如下:

createReports <- reactive({ 
annual <- (some data...) 
..... 
rmarkdown::render( 
input = RMD_FILE, 
output_format = "html_document", 
output_dir = "outputTest", 
quiet = TRUE 
) 

However, when I run this line, The Rmd file loads fine but I get this error:

然而,当我运行这一行时,Rmd文件加载良好,但是我得到了这个错误:

Quitting from lines 15-21 (5_Year_Average_Dividend_Growth_Rate.Rmd) 
Error in nrow(annual) : object 'annual' not found

However, as you can see, I have defined the variable annual within the same function as the rmarkdown::render. However, when it goes into the function render, it does not recognize that there is a variable called annual. I debugged it and right before it goes into rmarkdown::render, the annual variable does exist. How can I fix this?

但是,正如您所看到的,我已经在与rmarkdown:呈现相同的函数中定义了变量annual。然而,当它进入函数呈现时,它不知道有一个变量叫做annual。我调试它,在它进入rmarkdown::render之前,年度变量确实存在。我该怎么解决这个问题呢?

1 个解决方案

#1


0  

What you need is, in the rmarkdown document code chunk section where the variable annual is used, set the chunk to be

您需要的是,在使用变量annual的rmarkdown文档代码块部分中,将块设置为

```{r annual}
your_code_that_uses_annual_variable
```

#1


0  

What you need is, in the rmarkdown document code chunk section where the variable annual is used, set the chunk to be

您需要的是,在使用变量annual的rmarkdown文档代码块部分中,将块设置为

```{r annual}
your_code_that_uses_annual_variable
```