[英]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.