2016-04-02 21 views
1

Her bir listede bir karakter dizesi içeren bir liste nesnesi var ve her liste öğesindeki her bir karakter dizesi bir paragrafı temsil eder. Her bir paragrafı ayrı ayrı gösterebileceğim parlak bir uygulamada göstermeye çalışıyorum (arada yeni bir çizgi ile), ama bunu yapmanın bir yolu var mı diye anlayamadım.R Ekranda metin görünümü nasıl biçimlendirilir?

İşte ben bugüne kadar ne var:

shinyUI(
    fluidPage(

    # Application title. 
    titlePanel("M&A Clearing House"), 

    sidebarLayout(
    sidebarPanel(
     # Copy the line below to make a text input box 
     textInput("company", label = h3("Company Name"), value = "Enter text..."), 


     selectInput("year", "Choosing Year Range", 
        choices = c("2014", "2015", "2016"), 
        selected="2015", multiple=T), 

     actionButton("submit","Submit") 
    ), 

    mainPanel(
     tabsetPanel(
     tabPanel("All results", textOutput("allresult")) 
    ) 
    ) 
) 
)) 


shinyServer(function(input, output, session) { 

# ....assuming the result generated would look like this:... 
# exampletext <- list() 
# exampletext[[1]] <- "this is a paragraph" 
# exampletext[[2]] <- "this is another paragraph" 
# exampletext ....assuming the result generated would look like this:... 

    output$allresult <- renderPrint({ 
    return(unlist(exampletext())) 
    } 
) 

}) 

cevap

3

Sen gönderilmek istenen p etiketleri oluşturmak için listenizde lapply kullanabilirsiniz. UI kodu, bu ile textOutput değiştirin: Sunucu Kodu

htmlOutput("allresult") 

yerine bunu kullanın:

library(shiny) 
shinyApp(shinyUI(
    fluidPage(
    sidebarLayout(
     sidebarPanel(), 
     mainPanel(
     tabsetPanel(
      tabPanel("All results", 
        htmlOutput("allresult")) 
     ) 
    ) 
    ) 
) 
), 
shinyServer(function(input, output) { 
    exampletext <- rep(as.list("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."), 5) 
    output$allresult <- renderUI(lapply(exampletext, tags$p)) 
})) 
:
output$allresult <- renderUI(lapply(exampletext, tags$p)) 

İşte tam çalışma örneği
İlgili konular