在Shiny应用程序之外访问www文件可以通过以下解决方法:
library(shiny)
# 定义Shiny应用程序
ui <- fluidPage(
# 在www文件夹中的图像
img(src = "image.jpg", height = 200, width = 200)
)
server <- function(input, output) {
# 服务器逻辑
}
# 创建Shiny应用程序对象
shinyAppDir(appDir = "path/to/appdir", options = list(port = 8888))
在这个示例中,我们使用shinyAppDir
函数来指定Shiny应用程序的路径。这将确保Shiny应用程序在指定的目录中查找www文件夹。
library(shiny)
# 定义Shiny应用程序
ui <- fluidPage(
# 在www文件夹中的图像
img(src = "image.jpg", height = 200, width = 200)
)
server <- function(input, output) {
# 服务器逻辑
}
# 创建Shiny应用程序对象
shinyApp(ui = ui, server = server, options = list(port = 8888),
startHostname = "0.0.0.0", startUrl = "path/to/appdir")
在这个示例中,我们使用shinyApp
函数来创建Shiny应用程序对象。通过指定startUrl
参数,我们可以指定Shiny应用程序的路径。这将确保Shiny应用程序在指定的目录中查找www文件夹。
通过上述方法,可以在Shiny应用程序之外访问www文件夹。