I'm writing a Markdown file that uses a for
loop to produce a series of charts based on the contents of the data passed to them. I would like for the file to include some text before each chart that includes data based on the place in the for loop, so it can't be created outside the chunk. But when I try to use
print(paste("##This chart relates to", var[i]))
the output I get looks like
[1] "##This chart relates to Foobar"
What I want, is for the output text to be formatted as a H2 header. I tried adding the option results="asis"
to the chunk, but that had no discernible effect. What can I do?
Here's a sample of the relevant code:
```{r groupA, results="asis", warning=FALSE}
group<-"A"
tags<-unique(unlist(data$taglist[data$Group==group]))
for (i in 1:length(tags)) {
print(paste("###Commitments by ", group, " tagged as ",tags[i]))
commitcloud(data,group,tags[i])
```
答案 0 :(得分:0)
使用pander::pandoc.header()
:
pandoc.header(paste("Commitments by", group, "tagged as",tags[i]), level = 3)
level
表示标题的级别。
Per @ richard-telford - 如果您之前的内容有问题,请加cat("\n")
。表似乎特别麻烦。