'Shiny output in rmarkdown

I am looking to print the variable output_confomail into rmarkdown, however the code in the rmarkdown chunk is not producing the outcome, can someone help?

I did the same other times but never with a dataframe, nevertheless it should not change much...

Here is the R code

Name <- c("Jon", "Bill", "Maria", "Ben", "Tina")
Age <- c(23, 41, 32, 58, 26)
House <- c("Villa", "Villa", "Apartment", "Apartment", "Villa")
Company <- c("A", "B", "C", "D","E")



ui <- fluidPage( 
  sidebarLayout( 
    sidebarPanel(
      
    selectInput("trader", "Trader:", choices = df[,1],selected="NA"),
     
    ), 
        
    mainPanel(
      
      textOutput("company"), 

    ) 
  )
)

server <- function(input, output){
  
  output$company<-renderText(
    
    for(i in 1:123){
      if (df[i,1] == input$trader){
        return(df[i,4])
      }
    }
  )
 
}

shinyApp(ui = ui, server = server) ```

RMARKDOWN

``` ---
title: ""
output: html_document
date: '2022-03-23'
---

```{r, echo=FALSE, results = 'asis'}

output_confomail <- reactive ({
  for(i in 1:123){
    if(df[i,1] == input$trader){
      c("confo",df[i,4])
    }
  }
    
})

cat(output_confomail())``` 



Sources

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

Source: Stack Overflow

Solution Source