rShiny无法解析HTML
考虑以下应用程序:rShiny无法解析HTML,r,shiny,shinydashboard,R,Shiny,Shinydashboard,考虑以下应用程序: library(shiny) library(shinydashboard) library(shinyWidgets) tab_example <- tabItem(tabName = "example", fluidRow( column(6, h4("example"), includeHTML(&q
library(shiny)
library(shinydashboard)
library(shinyWidgets)
tab_example <-
tabItem(tabName = "example",
fluidRow(
column(6,
h4("example"),
includeHTML("example.html")
)
)
)
body <-
dashboardBody(
tabItems(
tab_example
)
)
sidebar <-
dashboardSidebar(
sidebarMenu(
menuItem("Example", tabName = "example", icon = icon("bullseye"))
)
)
ui <-
dashboardPage(
dashboardHeader(title = "EXAMPLE"),
sidebar,
body
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
这是它应该运行的,但是当运行一个更复杂的带有文件夹结构的示例时,它无法解析
文件夹结构:
├── example
│ └── example.html
├── dashboard.R
├── ui_elements
│ └── sidebar.R
│ └── body.R
│ └── tabs
│ └── tab_example.R
选项卡\u示例.R
:
source("example/example.html")
tab_example <-
tabItem(tabName = "example",
fluidRow(
column(6,
includeHTML("example.html")
)
)
)
source(“example/example.html”)
tab_示例查看源代码中的帮助,标题显示:
从文件、连接或表达式中读取R代码
但是,您尝试读取HTML文件,因此失败。您只需在includeHTML
中指定正确的路径即可:
includeHTML("example/example.html")
并且不需要使用source
Error in source("example/example.html") :
example/example.html:1:1: unexpected '<'
1: <
includeHTML("example/example.html")