我想使用server.r上生成的list()来填充ui.r中的段落
server.r
shinyServer(function(input, output) {
output$out <- reactive({
list(
a = 'brown',
b = 'quick',
c = 'lazy'
)
})
})
长子。 [R
library(shiny)
shinyUI(fluidPage(
p('The ', output$out$a, output$out$b, 'fox jumps over the ', output$out$c, 'dog')
))
我知道代码不正确,你必须使用辅助函数来访问ui.r中的数据,但我只是想说明我的问题。
也许我不理解你的意图,但看看这个:
library(shiny)
server <- function(input, output) {
out <- reactive({
tmp <- list()
tmp <- list(
a = 'brown',
b = 'quick',
c = 'lazy'
)
return(tmp)
})
output$a <- function() {
out()[[1]]
}
output$b <- function() {
out()[[2]]
}
output$c <- function() {
out()[[3]]
}
}
ui <- shinyUI(fluidPage(
p('The ', textOutput("a"), textOutput("b"),
'fox jumps over the ', textOutput("c"), 'dog')
))
shinyApp(ui, server)