我需要以某种方式为系统提供R图像,该系统仅允许我使用HTML的子集,因此没有iframe。基本上,它必须类似于`img src =“ https://shinyserver.com/app/image123.jpeg”/'。
我正在考虑使用https://github.com/Appsilon/shiny.router,但不确定是否可以使用。
有人有建议吗?
答案 0 :(得分:1)
我不确定这是否能真正解决您的问题,但是由于您提到了L3C<char>::func()
,所以我认为shiny.router
软件包也可能有用。
这是一个小示例,可让您使用R函数作为API创建图像标签。
水管工R
plumber
然后,您必须输入以下内容来启动管道工API:
library(shiny)
library(plumber)
#' Get an image tag with source from its name
#' @param imgsrc Source of the image
#' @get /
img2tag <- function(imgsrc = "") {
url = paste0('https://shinyserver.com/app/', imgsrc)
as.character(tags$img(src=url))
}
然后您可以通过以下方式在浏览器中访问它:
pr <- plumber::plumb("plumber.R")
pr$run(port = 7818)
为您提供字符串的JSON等效:
http://localhost:7818/?imgsrc=image123.jpeg
或通过控制台输入:
0 "<img src=\"https://shinyserver.com/app/image123.jpeg\"/>"