作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 RStudio 的 Shiny 进行基本的 MBTI 性格测试。用户回答四个问题,并获得他的性格类型(例如 ENTJ)以及相应的维基百科链接以阅读有关他的类型的更多信息(例如 https://en.wikipedia.org/wiki/ENTJ )。
为此,首先,我使用 actionButton,如 here 所述.其次,我在 server.R 中使用了一堆函数来制作一个有效的网络链接:
shinyServer(function(input, output) {
# After the Submit button is clicked
init <- reactiveValues()
observe({
if(input$submit > 0) {
init$pasted <- isolate(paste("Your personality type is ",
input$b1, input$b2, input$b3, input$b4, sep=""))
init$link <- paste("https://en.wikipedia.org/wiki/",
input$b1, input$b2, input$b3, input$b4, sep="")
init$linktext <- a("Find out more about it here", href=init$link, target="_blank")
}
})
# Output
output$text1 <- renderText({
init$pasted
})
output$text2 <- renderText({
init$linktext
})
})
问题是,当我运行该应用程序时,init$pasted 工作得很好,而 init$linktext 没有 - 说
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'list') cannot be handled by 'cat'
有什么解决办法吗?谢谢!
最佳答案
a(...)
的输出是一个列表,不能使用 renderText
呈现。您可以在服务器端的 ui.R
和 renderUI
中使用 htmlOutput
,这是一个示例:
server <- function(input, output) {
output$html_link <- renderUI({
a("Find out more about it here", href=paste("https://en.wikipedia.org/wiki/","a","b","c","d", sep=""), target="_blank")
})
}
ui <- shinyUI(fluidPage(
htmlOutput("html_link")
))
shinyApp(ui = ui, server = server)
关于r - 在 R 中使用 Shiny : how to make a weblink work in the output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31952914/
我是一名优秀的程序员,十分优秀!