我试图找到一种从文本输入交互式修改应用程序主题的方法.
这是我的ui.R.的一个例子.
shinyUI(fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),theme = input$skin
)
)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:"错误:对象'输入'未找到"
作为最后一点,我在app文件夹中创建了一个foler www,其中包含bootstrap1.css和其他css文件.
该theme选件fluidPage是插入一个CSS脚本以下调用:
tags$head(tags$link(rel = "stylesheet", type = "text/css",
href = input$Skin))
Run Code Online (Sandbox Code Playgroud)
你可以在你的ui中添加这个html作为一个反应元素:
library(shiny)
runApp(list(ui = fluidPage(
tabsetPanel(
tabPanel("Main"),
tabPanel("Settings",
textInput("Skin", "Select Skin", value = "bootstrap1.css")
), type = "pills", position = "above"
),
uiOutput("myUI")
)
, server = function(input, output, session){
output$myUI <- renderUI({
tags$head(tags$link(rel = "stylesheet", type = "text/css",
href = input$Skin))
})
}
))
Run Code Online (Sandbox Code Playgroud)