0

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]]

}



Andrew A
  • 185
  • 2
  • 11
Ben
  • 181
  • 6
  • 1
    Have you tried wrapping in `print()`? See: https://stackoverflow.com/questions/11956520/r-knitr-markdown-output-plots-within-for-loop – langtang Apr 27 '22 at 22:29
  • I think I know why, it's plotly – Ben Apr 27 '22 at 22:36
  • 1
    https://stackoverflow.com/questions/49990653/plotly-plot-doesnt-render-within-for-loop-of-rmarkdown-document – Ben Apr 27 '22 at 22:36

0 Answers0