How to output my uploaded text in Shiny in R at the position of the screenshot?

I would like to position a long text on the right side of this Shiny app, as shown on the screenshot below.

    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='image.jpg', align = right),
    
    #titlePanel(title=div(img(src=image.jpg))),
    
    fluidRow(HTML(strong Search Bar)),
    #fluidRow(HTML( strongDate: 06-29-2020/strong) ),
    
    fluidRow(
      br(),
      p(User Name : )),
    br(),
    br(),
    
    fluidRow(HTML(strongEnter 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'))
      })
    }
       

here is the rcloud link of the project to experiment with : https://rstudio.cloud/project/1497912

Topic rstudio r

Category Data Science


You can run the shiny application, open it in chrome - using google chrome inspector you find the css class titles and add custom css.


In your code you use the Sidebar layout which allows only two columns, instead you should use the grid layout to position your elements where you want them, see https://shiny.rstudio.com/articles/layout-guide.html.

You probably need something like this (not tested):

ui<- shinyUI(fluidPage(
  fluidRow(
    column(3,
      # content left 
    ),
    column(5,
      # content centre
    ),
    column(4,
      # content right
    )
  )
)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.