r - 在 Shiny 中直接访问 Webshot 图像
问题描述
目标:创建网站的屏幕截图,当用户输入基因名称时自动显示,例如 TP53、NAPRT
问题:虽然这在本地有效,但当我在线发布时它失败了。我怀疑这是因为从 webshot 下载的文件不再可访问。我试图用 www/Filename.png 指定文件名,但这既适用于所有基因,也适用于在线仅适用于那些之前已经创建的基因,因此图片已经存在于 www
如您所见,运行它 R 有效,但发布它没有。
library(webshot)
# Define UI for application that draws a histogram
ui <- fluidPage(
textInput("gene", "Gene symbol", value = "TP53"),
imageOutput('myImage')
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$myImage <- renderImage({
outfile <- paste(input$gene,'.png', sep="")
owd <- setwd(tempdir())
webshot(paste('http://ualcan.path.uab.edu/cgi-bin/Pan-cancer.pl?genenam',input$gene,sep="="),
outfile,
selector = '#banner3',
delay = 2,
expand = c(0,40,0,0))
# Return a list containing the filename
list(src = outfile,
contentType = 'image/png',
width = 600,
height = 450,
alt = "This is alternate text")
}, deleteFile = FALSE)
}
# Run the application
shinyApp(ui = ui, server = server)```
解决方案
推荐阅读
- python - 当每个函数立即终止时,为什么这里会出现 RecussionError?
- reactjs - 表单值未在上下文 api React 中更新
- go - 上传签名的 URL 永远不会收到响应/卡住
- java - 如何在 Android Studio 中将文本设置为对应的图像
- java - 错误:操作总是访问存储库。不建议在没有交易的情况下这样做
- java - 如何在spring boot中编写用于聚合的junit测试用例
- geocoding - HERE 地理编码和搜索 API v7 - 搜索特定食物类型不起作用
- batch-file - 使用 cmd 移动具有特定文件名掩码的文件
- java - Minecraft forge 无法解析符号“net”
- android-biometric - 我可以获得存储指纹的标识符吗?