我正在尝试在shinydashboard中创建一个启动或着陆页(如果需要,可以创建闪亮的页面).我的主要闪亮应用程序将有标签导航等,但登陆页面不应该.事实上,它应该完全不同,可能类似于:http://www.dataseries.org
我知道我可以将html页面添加到与ui.r和server.r脚本相同的文件夹中,但是当应用程序启动时我还没有找到引用该文件的方法.锚标记可以在那里提供链接,但我希望登录页面在调用页面时自动打开.
我可重复的代码是没有价值的,因为没有任何工作,但我还是包括它,以防它变得更容易.这是来自shinydashboard网站的样板.
ui.r
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
## ui.R ##
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
) …Run Code Online (Sandbox Code Playgroud) 我正在使用shinydashboard,并且需要构建两级嵌套子菜单.我正在尝试这个并且不会起作用:
library(shinydashboard)
sidebar <- dashboardSidebar(
sidebarMenu(id = 'sidebarmenu',
menuItem('x', tabName = 'x', icon = icon('line-chart')),
menuItem('y', tabName = 'y',
icon = icon('line-chart'),
menuSubItem('a',
tabName = 'a',
icon = icon('line-chart')),
menuSubItem('b',
tabName = 'b',
icon = icon('line-chart'),
menuSubItem('l',
tabName = 'l',
icon = icon('line-chart')),
menuSubItem('m',
tabName = 'm',
icon = icon('line-chart'))),
menuSubItem('c',
tabName = 'c',
icon = icon('line-chart'))
)))
Run Code Online (Sandbox Code Playgroud)
给我错误:
Error in menuSubItem("b", tabName = "b", icon = icon("line-chart"), menuSubItem("l", :
Can't specify both href and tabName
Run Code Online (Sandbox Code Playgroud)
是否有可能建立两级嵌套?当然,上面的删除l和m …
我正在使用文档https://shiny.rstudio.com/tutorial/writing-tutorial/lesson2/,更准确地说,使用以下代码向我的闪亮页面添加一个简单的段落:
ui <- fluidPage(
titlePanel("My Shiny App"),
sidebarLayout(
sidebarPanel(),
mainPanel(
p("p creates a paragraph of text."),
p("A new p() command starts a new paragraph. Supply a style attribute to change the format of the entire paragraph.", style = "font-family: 'times'; font-si16pt"),
strong("strong() makes bold text."),
em("em() creates italicized (i.e, emphasized) text."),
br(),
code("code displays your text similar to computer code"),
div("div creates segments of text with a similar style. This division of text is all blue because I …Run Code Online (Sandbox Code Playgroud) 我正在使用闪亮的仪表板模板来生成我的Web UI.
当计算完成时,我想动态生成一个信息框,其链接指向其中一个tabItems dashboardBody.
例如,我可以把它放在我的tabItem1输出中,
renderInfoBox({
infoBox("Completed",
a("Computation Completed", href="#tabItem2"),
icon = icon("thumbs-o-up"), color = "green"
)
})
Run Code Online (Sandbox Code Playgroud)
但问题是,当我点击链接时,它什么也没做.我想跳到tabItem2.当我将鼠标悬停在它上面时,链接href似乎有效.
谢谢!
更新:除了使用Javascripts之外,看起来像使用actionLink和包中的updateTabItems函数shinydashboard也可以.
我有一个shiny使用plotly和渲染的情节ggplot2.但是,我不希望显示悬停时出现的选项栏.有没有办法使用ggplotly(p)和删除选项栏?
我没有一个可重复的例子,因为问题更多的是模块如何工作.我试图了解如何将一些反应函数从一个模块传递到下一个模块.我在过去收到过有关使用ObserveEvent的回复,但是当我在一个模块中使用反应值来在另一个模块中执行某些其他操作时它们似乎无法工作
module1 <- function(input, output, session){
data1<-reactive({
#some reacttive funcion that produces an output
})
data2<-reactive({
#some reacttive funcion that produces another output
})
return(list(data1,data2))
}
module2 <- function(input, output, session,data1){
observe( data1(), {
#perform some other functions here using data1().e.g reading or parsing data
})
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我有一个module1,它返回data1和data2的两个输出
我想在模块2中使用data1的值,并使用该值执行一些新操作.
我在这里看了类似问题的其他答案,但我仍然不理解它们.如果有人可以帮助我更清楚地解释这个概念,那将非常有用,感谢您的帮助
使用时shinydashboard我发现有些图标似乎有效,而有些则没有.在下面的示例中,当clock-o图标正常工作时,电池已满的图标不起作用.我无法弄清楚为什么会发生这种情况.
library(shiny)
library(shinydashboard)
header <- dashboardHeader(title="Some Icons Not Working?")
# No sidebar --------------------------------------------------------------
sm <- sidebarMenu(
sm <- sidebarMenu(
menuItem(
text="asdf",
tabName="asdfasdf",
icon=icon("battery-full")),
menuItem(
text="qwer",
tabName="qwerqwer",
icon=icon("clock-o"))
)
)
sidebar <- dashboardSidebar(sm)
# Compose dashboard body --------------------------------------------------
body <- dashboardBody(
tabItems(
)
)
# Setup Shiny app UI components -------------------------------------------
ui <- dashboardPage(header, sidebar, body, skin="black")
# Setup Shiny app back-end components -------------------------------------
server <- function(input, output) {
}
# Render Shiny app --------------------------------------------------------
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud) 我有两个selectInputs,我想在第一个(Brand)中选择更改第二个(Candy)中的可能选择.因此,例如,如果有人在第一个输入框中选择了"雀巢",那么只有雀巢糖果将出现在第二个框中.我的数据表有一个Brand列和一个Candy bar类型列.
我有以下代码开始,但这显示了所有选项,无论选择如何.
selectInput(inputId="brand",
label="Brand:",
choices=as.character
(unique(candyData$Brand)),
selected = "Nestle"
),
selectInput(inputId="candy",
label="Candy:",
choices=as.character
(unique(candyData$Candy)),
selected = "100Grand"
Run Code Online (Sandbox Code Playgroud)
数据集如下所示:
Brand Candy
Nestle 100Grand
Netle Butterfinger
Nestle Crunch
Hershey's KitKat
Hershey's Reeses
Hershey's Mounds
Mars Snickers
Mars Twix
Mars M&Ms
Run Code Online (Sandbox Code Playgroud)
更新的问题 如何根据后续过滤更新仪表板中的ValueBox?
output$count <- renderValueBox({
valueBox(
value = nrow(candyData),
subtitle = "Number of Candy Bars",
icon = icon("table")
)
})
Run Code Online (Sandbox Code Playgroud) 我想自定义我的闪亮应用程序的框状态的颜色.我找到一种css方式来改变这些盒子的盒子背景颜色,但不是自定义状态颜色,但是我没有在css中看到等效的"status"参数?因此,我打印一个包含所考虑的参数"status"的简单页面的源代码,我正在查看它的类(我认为class ="box box-solid box-primary")但我无法在几个中找到它.css在这个网页上提供...... :(
你有好主意吗 ?
这是一个简单的代码:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(width = 6, title = "youhou", status = "primary", solidHeader = TRUE,
"Box content"
)
)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
预先感谢您的任何帮助 !
查
是否可以在旁边的水平栏中放置一些物品dashboardHeader?我知道你可以notificationItem像这个例子一样放在最右边.但我想使用与dashboardSidebar添加过滤器等相同的选项.我想在顶部使用这样的过滤器:

r ×10
shiny ×10
shinydashboard ×10
box ×1
css ×1
filter ×1
font-awesome ×1
ggplot2 ×1
plotly ×1
shiny-server ×1
shinyapps ×1