1

i need to do the following

for (j in 1:n){

´´´{r}
print(list1[[j]])
´´´
$//$
$//$
$//$
´´´{r}
print(list2[[j]])
´´´

}

That is I need to iterate over code chunks is R markdown.

How can i do that?

stefanR
  • 79
  • 1
  • 7

1 Answers1

2

You could use results='asis chunck option:

---
title: "test"
output: html_document
---


```{r, results='asis', echo = FALSE}
n <- 3
list1 <- lapply(1:n,function(i) LETTERS[i])
list2 <- lapply(1:n,function(i) i)
for (j in 1:n){
cat(list1[[j]],'\n\n')
cat('$//$ \n\n')
cat(list2[[j]],'\n <br> <br> <br>\n')
}
```

enter image description here

Waldi
  • 39,242
  • 6
  • 30
  • 78