I want to print the content of the writeLines in new lines but I am not being able to in my Shiny app. The relevant server code is attached. The text in the box is coming out as if it is concatenated and not in new lines. Can someone please help me?
Updated Reproducible Example
shinyUI(dashboardPage( skin = "black",
dashboardHeader(title = "Fruits",titleWidth = 450),
dashboardSidebar(width=250,tags$head(
tags$style(HTML("
.sidebar { height: 90vh; overflow-y: auto; font-size: 17px;}
" )
)
),
sidebarMenu(
menuItem("Fruits", tabName = "Fruits"),
fileInput("file","Upload file (.xlsx)", multiple = TRUE,accept = c(".xlsx")),
uiOutput("selectfile"),
)),
dashboardBody(
tabItems(
tabItem(tabName = "Fruits",
fluidPage(
uiOutput("tb")
)
)))))
shinyServer(function(input, output, session)
{
fruits <- reactive({
req(input$file)
inFile <- input$file
if(is.null(inFile))
return(NULL)
fruits<-read_excel(paste(inFile$datapath, ".xlsx", sep=""), sheet = 1)
})
data <- reactive({
data<-data.frame(fruits())
})
output$text1<- renderPrint({
for(i in 1:length(data()$fruit_column)){
writeLines(paste("Fruit", i ,"is", data()[i,fruit_column]))
}
})
output$tb <- renderUI({
if(is.null(input$file)) {return()}
else
tabsetPanel(
tabPanel("Tab 1",
box( title = "Fruit Log", status = "primary", solidHeader = TRUE,
collapsible = TRUE,
textOutput("text1")))
)
})
})
shinyApp(ui, server)
This should give a rough idea of the app I have created although this reproducible example might have errors