【发布时间】:2013-10-28 11:54:56
【问题描述】:
我对 r 和闪亮仍然很陌生,而且我对原本应该是简单逻辑的东西感到困惑。我正在尝试在 imageOutput 小部件中显示 pdf 文件,但没有运气。有人可以引导我朝着正确的方向前进吗?
示例 ui.R
shinyUI(pageWithSidebar(
mainPanel(
selectInput("sel_ed",
label = "View outputs for Ecodistrict:",
choices = c(244,245,247,249),
selected = NULL,
multiple = FALSE),
imageOutput("imp_pdf",width="500px",height="500px")
))
示例服务器.R
shinyServer(function(input, output, session) {
importance <- function(inputSpecies){
img_dir <- pdf(paste(inputSpecies,"\\models\\MATL\\MATRF_Importance",sep=""))
}
output$imp_pdf <- renderImage({importance(input$sel_ed)})
})
我得到的大多数错误都与预期的字符向量参数或原子向量有关。我知道闪亮的设计或多或少是为了渲染和显示图像或绘图,但必须有一种方法来显示已经在本地驱动器上的 pdf。
【问题讨论】:
-
可能不相关,但您可以使用
/作为路径而不是 \\ 即使在 Windows 中 -
我认为目前没有现成的组件。当然,您可以在网页中显示 pdf。如果它可以在 webapge 中完成,那么闪亮可以适应它。见github.com/mozilla/pdf.js
标签: r image pdf shiny displayobject