[英]Shiny reactivity with IncludeMarkdown?
试图将这些想法更进一步:
我想在mainPanel
包含一个反应性markdown文件( *.Md
),条件是selectInput
的输入。 我该怎么做?
我试着在变化renderText
, renderPrint
使用eval
内includeMarkdown
。 到目前为止似乎没有任何工作。
例如。
### ui.R
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("var1",
label= "Please Select option",
choices= c("option1", "option2", "option3"),
selected= "option1"
),
mainPanel(
h3("guide:")
includeMarkdown("md_file")
)
)
))
### server.R
shinyServer(function(input, output) {
output$md_file <-
if (input$var1 == "option1") {
renderPrint({"option1.Md"})
} else if (input$var1 == "option2") {
renderPrint({"option2.Md"})
} (input$var1 == "option3") {
renderPrint({"option3.Md"})
}
})
})
R> shiny::runApp('C:/Shiny_demo')
听http://127.0.0.1:6421
readLines(con)中的警告:
无法打开文件'md_file':没有这样的文件或目录
readLines(con)出错:无法打开连接
根据与Shiny Google小组中Joe Cheng的讨论,答案是:
在您的UI中:
uiOutput("md_file")
在您的服务器中:
output$md_file <- renderUI({
file <- switch(input$var1,
option1 = "option1.Md",
option2 = "option2.Md",
option2 = "option3.Md",
stop("Unknown option")
)
includeMarkdown(file)
})
谢谢,乔!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.