Why does cat content gets printed many times when I use it with a program sourced by shiny


This is a simple statement. It belongs to a program sourced by shiny. The message gets displayed in the UI.
After a series of statements like the mapFns below, the output of the cat statement that follows gets printed many times. Why is this happening?

mapFns<- mapFns[grep("_SiteCounts.tsv", mapFns, invert=T)]

if (length(mapFns)>0) {
         cat("There may be merge_MAP files in OUTpath, among these files:\n")

Not sure what's going on, but could you please add the requisite backticks around your code chunk for formatting? It makes it much more legible.


Sure, Thanks. I just did.

My first guess would be that this block of code is getting called by a reactive value that is updating several times.

1 Like

This block of code is not called by a reactive value. Is part of a program that the App uses by inserting "source("folder"). The block of code is neither used by the UI, nor by the server function. When the sourced program runs the cat and print statements, their respective messages get printed in the UI main panel. I wanted to take advantage of the fact that the statements get displayed so I do not have to use renderText, but I do not understand why they would not be displayed only once.

I will make a small program to test and see if this is something that happens when cat is displayed in the Shiny UI.