'Displaying plots from a loop in Rmarkdown html format with parameters

I have a hard time trying to understand what happened here, I have a list params$output_file to return through R shiny app. It didn't work if I use loop, it just worked only outside loop

If I used outside loop, it worked. I have been spent a whole day try to figure out, but I have no luck, if anyone points out what wrong with it. I am appreciated. enter image description here

The plots showed up, which were outside the loop, but there is nothing inside loop

---
title: Test
output: html_document
params:
  output_file: NA
---




```{r  results='asis', echo=FALSE, cache=TRUE}
library(knitr)

# Outside loop, it is working
params$output_file[[1]]


params$output_file[[2]]


params$output_file[[3]]



for(i in seq_along(params$output_file)){
  
  print("Inside Loop print nothing")

  params$output_file[[i]]

}





Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source