[英]creating a list/ vector of text from shiny
我們可以創建閃亮的輸入矢量/輸入列表嗎? 我想創建一個字符串向量,該向量將所有從輸入中采取的操作存儲為閃亮的。
這是示例代碼,因此,只要我們更改輸入,輸出就會在同一行中更改。
require(shiny)
runApp(list(ui = pageWithSidebar(
headerPanel("censusVis"),
sidebarPanel(
helpText("Create demographic maps with
information from the 2010 US Census."),
selectInput("var",
label = "Choose a variable to display",
choices = c("Percent White", "Percent Black",
"Percent Hispanic", "Percent Asian"),
selected = "Percent White"),
sliderInput("range",
label = "Range of interest:",
min = 0, max = 100, value = c(0, 100))
),
mainPanel(htmlOutput("text")
)
),
server = function(input, output) {
output$text <- renderUI({
str1 <- paste("You have selected", input$var)
})
}
)
)
希望看到動態輸出為(具體來說,它可以是n個輸出...)
[1] You have selected Percent White
[2] You have selected Percent Asian
[3] You have selected Percent Black
這樣的東西?
require(shiny)
runApp(list(ui = pageWithSidebar(
headerPanel("censusVis"),
sidebarPanel(
helpText("Create demographic maps with
information from the 2010 US Census."),
selectInput("var",
label = "Choose a variable to display",
choices = c("Percent White", "Percent Black",
"Percent Hispanic", "Percent Asian"),
selected = "Percent White"),
sliderInput("range",
label = "Range of interest:",
min = 0, max = 100, value = c(0, 100))
),
mainPanel(verbatimTextOutput("text")
)
),
server = function(input, output) {
val<-reactiveValues()
val$txt<-""
observeEvent(input$var,{
new<-paste("You have selected", input$var)
val$txt<-paste( val$txt,new,sep='\n')
})
output$text <- renderText({
str1 <- val$txt
})
}
)
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.