How to output uploaded text on the main page of Shiny

I would like Shiny to output the full text file I uploaded to be displayed in the screenshot position. What changes I might need for that?

this is the rcloud link for the project to experiment with : Posit Cloud

part of text uploaded : “Well, Prince, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don’t tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist—I really believe he is Antichrist—I will have nothing more to do with you and you are no longer my friend, no longer my ‘faithful slave,’ as you call yourself! But how do you do? I see I have frightened you—sit down and tell me all the news.”

It was in July, 1805, and the speaker was the well-known Anna Pávlovna Schérer, maid of honor and favorite of the Empress Márya Fëdorovna. With these words she greeted Prince Vasíli Kurágin, a man of high rank and importance, who was the first to arrive at her reception. Anna Pávlovna had had a cough for some days. She was, as she said, suffering from la grippe; grippe being then a new word in St. Petersburg, used only by the elite.

All her invitations without exception, written in French, and delivered by a scarlet-liveried footman that morning, ran as follows:

“If you have nothing better to do, Count (or Prince), and if the prospect of spending an evening with a poor invalid is not too terrible, I shall be very charmed to see you tonight between 7 and 10—Annette Schérer.”

“Heavens! what a virulent attack!” replied the prince, not in the least disconcerted by this reception. He had just entered, wearing an embroidered court uniform, knee breeches, and shoes, and had stars on his breast and a serene expression on his flat face. He spoke in that refined French in which our grandfathers not only spoke but thought, and with the gentle, patronizing intonation natural to a man of importance who had grown old in society and at court. He went up to Anna Pávlovna, kissed her hand, presenting to her his bald, scented, and shining head, and complacently seated himself on the sofa.

library(quanteda)
library(shiny)
library(tm)
library(tidytext)
library(tidyverse)
library(shinydashboard)
library(shinythemes)


war <- readLines("war.txt")

war_corpus <- corpus(war)

sentences <- tokens(war_corpus,what="sentence")

make_sentences <- function(word) {
  grep(word,sentences,value=TRUE)}

make_sentences("prince")


ui<- shinyUI(fluidPage(
  
  # Application title
  mainPanel(
    img(src='spsimage.jpg', align = "right"),
    
    #titlePanel(title=div(img(src="image.jpg"))),
    
    fluidRow(HTML("<strong>Search Bar")),
    #fluidRow(HTML(" <strong>Date: 06-29-2020</strong>") ),
    
    fluidRow(
      br(),
      p("User Name : ")),
    br(),
    br(),
    
    fluidRow(HTML("<strong>Enter a word.Click \"Next words\" after</strong>") ),
    fluidRow( p("\n") ),
    
    # Sidebar layout
    sidebarLayout(
      
      sidebarPanel(
        textInput("inputString","Enter a word here",value = " "),
        submitButton("Next words")
      ),
      
      mainPanel(
        h4("Are you looking for this ?"),
        tags$style("#mytext {white-space: pre-line;}"),
        verbatimTextOutput("mytext")
        
      )
    )
  )))


server <- function(input, output, session) {
  output$mytext <- renderPrint({
    
    sentences <- make_sentences(input$inputString)
    length(sentences)
    cat(paste0(1:length(sentences),"  ",sentences,sep= '\n'))
  })
}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.