数据集名称如何在一个文件夹中使用?
例如,在下面的针织R代码块中,使用deparse(substitute(x))
(通常在非针织R代码中工作)不会显示针织HTML子文档中cities
列表中的New York
和Berlin
:
```{r plot-data, results='asis'}
cities <- list(New York, Berlin)
res <- lapply(cities, function(x) {
knitr::knit_child(
text = c(
'\n',
'## `r deparse(substitute(x))`',
'\n',
'```{r, out.height="100%", out.width="100%"}',
'some_plotting_function(x)',
'```'
),
envir = environment(),
quiet = TRUE
)
})
cat(unlist(res), sep = "\n")
```
也就是说,在##注释行中,输出的城市名称分别显示为X[[i]]
,而不是New York
和Berlin
.(在拨打some_plotting_function()
之前,我想使用城市名称作为部分标题.)