But I dont want to write 3 chunks just to enter heading in R markdown.
I can write code in one chink as below. But how do i add heading within code chunk in for loop. So every new loop we enter new heading in ouput generated.
```{r, echo=FALSE, include= FALSE}
x=3
for( i in 1:x)
{
####here i want to insert heading after vry loop in Markdown with value of Names[i]###
print(Names[i])
}
```
OK, now I understand what you mean by heading. I don't think it's possible to do that.
But on the other hand, I think the general case of printing sets of text or numbers is better handing with printing data frames or printing html tables with kable, so I stick with my original answer!
Add results asis to the chunk option, needs echo false and include true.
``` {r chunk name, echo=FALSE, include= T, results="asis"}
x=3
for( i in 1:x)
{
####here i want to insert heading after vry loop in Markdown with value of Names[i]###
cat(paste("#",Names[i],"\n"))
}