SCI医学科研助手
生信分析-Meta分析-基础实验

R包shiny开发网页–5.shinydashboard的标题栏

今天是生信星球陪你的第133天


   你想找辆共享单车,发现满街都是别家车,没有一辆你能骑。

   你想学点生信,搜了“初学者教程”,满眼尽是高大上,没有一句能看懂。

   终于你跨越茫茫宇宙,来到生信星球,发现了初学者的新大陆!

  今天在小丫画图群蹭了一波推公众号,结果“涨幅喜人呐”–我引用的。豆豆和花花欢迎新朋友哇,感谢小丫姐姐~放个链接–新学期,老板将对我刮目相看!

  小洁写于2018.9.20 今天豆豆继续被函数困住。而且不让我截图啦明天下班,就可以去找他过中秋节了(可是我还没买到票啊)希望明天可以有。去年和今年的6-9月豆豆被派去基地了,明天可能是这辈子的长期异地恋最后一天啊中秋节后他就跟我一起回北京了,想想就开心。看正文啦!

系列教程:

R包shiny开发网页–1. 初见

R包shiny开发网页–2.UI

R包shiny开发网页–3.认识shinydashboard

R包shiny开发网页–4.shiny结构模板

标题栏

可以包括标题和下拉菜单。

(1)标题

dashboardHeader(title = "My Dashboard")

(2)消息菜单

dropdownMenu(type = "messages",
  messageItem(
    from = "Sales Dept",
    message = "Sales are steady this month."
  ),
  messageItem(
    from = "New User",
    message = "How do I register?",
    icon = icon("question"),
    time = "13:45"
  ),
  messageItem(
    from = "Support",
    message = "The new server is ready.",
    icon = icon("life-ring"),
    time = "2014-12-01"
  )
)

(3)通知菜单

dropdownMenu(type = "notifications",
  notificationItem(
    text = "5 new users today",
    icon("users")
  ),
  notificationItem(
    text = "12 items delivered",
    icon("truck"),
    status = "success"
  ),
  notificationItem(
    text = "Server load at 86%",
    icon = icon("exclamation-triangle"),
    status = "warning"
  )
)

(4)任务菜单

dropdownMenu(type = "tasks", badgeStatus = "success",
  taskItem(value = 90, color = "green",
    "Documentation"
  ),
  taskItem(value = 17, color = "aqua",
    "Project X"
  ),
  taskItem(value = 75, color = "yellow",
    "Server deployment"
  ),
  taskItem(value = 80, color = "red",
    "Overall project"
  )
)

附上正确的全套臃肿代码:

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard",
                  dropdownMenu(type = "notifications",
                               notificationItem(
                                 text = "5 new users today",
                                 icon("users")
                               ),
                               notificationItem(
                                 text = "12 items delivered",
                                 icon("truck"),
                                 status = "success"
                               ),
                               notificationItem(
                                 text = "Server load at 86%",
                                 icon = icon("exclamation-triangle"),
                                 status = "warning"
                               )
                  ),
                  dropdownMenu(type = "messages",
                               messageItem(
                                 from = "Sales Dept",
                                 message = "Sales are steady this month."
                               ),
                               messageItem(
                                 from = "New User",
                                 message = "How do I register?",
                                 icon = icon("question"),
                                 time = "13:45"
                               ),
                               messageItem(
                                 from = "Support",
                                 message = "The new server is ready.",
                                 icon = icon("life-ring"),
                                 time = "2014-12-01"
                               )
                  ),
                  dropdownMenu(type = "tasks", badgeStatus = "success",
                               taskItem(value = 90, color = "green",
                                        "Documentation"
                               ),
                               taskItem(value = 17, color = "aqua",
                                        "Project X"
                               ),
                               taskItem(value = 75, color = "yellow",
                                        "Server deployment"
                               ),
                               taskItem(value = 80, color = "red",
                                        "Overall project"
                               )
                  )
  ),
  dashboardSidebar(),
  dashboardBody()
)
server <- function(input, output) {
  output$messageMenu <- renderMenu({
    msgs <- apply(messageData, 1function(row) {
      messageItem(from = row[["from"]], message = row[["message"]])
    })
    dropdownMenu(type = "messages", .list = msgs)
  })
}
shinyApp(ui, server)

优化一下

library(shiny)
library(shinydashboard)
d1 <- dropdownMenu(type = "notifications",
                   notificationItem(
                     text = "5 new users today",
                     icon("users")
                   ),
                   notificationItem(
                     text = "12 items delivered",
                     icon("truck"),
                     status = "success"
                   ),
                   notificationItem(
                     text = "Server load at 86%",
                     icon = icon("exclamation-triangle"),
                     status = "warning"
                   )
)
d2 <- dropdownMenu(type = "messages",
                   messageItem(
                     from = "Sales Dept",
                     message = "Sales are steady this month."
                   ),
                   messageItem(
                     from = "New User",
                     message = "How do I register?",
                     icon = icon("question"),
                     time = "13:45"
                   ),
                   messageItem(
                     from = "Support",
                     message = "The new server is ready.",
                     icon = icon("life-ring"),
                     time = "2014-12-01"
                   )
)
d3 <- dropdownMenu(type = "tasks", badgeStatus = "success",
                   taskItem(value = 90, color = "green",
                            "Documentation"
                   ),
                   taskItem(value = 17, color = "aqua",
                            "Project X"
                   ),
                   taskItem(value = 75, color = "yellow",
                            "Server deployment"
                   ),
                   taskItem(value = 80, color = "red",
                            "Overall project"
                   )
)
ui <- dashboardPage(
  dashboardHeader(title = "My Dashboard",d1,d2,d3),
  dashboardSidebar(),
  dashboardBody()
)
server <- function(input, output) {
  output$messageMenu <- renderMenu({
    msgs <- apply(messageData, 1function(row) {
      messageItem(from = row[["from"]], message = row[["message"]])
    })
    dropdownMenu(type = "messages", .list = msgs)
  })
}
shinyApp(ui, server)

(5)不显示标题栏

dashboardHeader(disable = TRUE)


简书-小洁忘了怎么分身,同步更新花花的文章。

简书-刘小泽,同步更新豆豆的文章

扫描二维码可以加我好友。


点击底部的“阅读原文”,获得更好的阅读体验哦?

初学生信,很荣幸带你迈出第一步。

我们是生信星球,一个不拽术语、通俗易懂的生信知识平台。由于是2018年新号,竟然没有留言功能。需要帮助或提出意见请后台留言、联系微信或发送邮件到Bioplanet520@outlook.com,每一条都会看到的哦~


 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:医学SCI科研之家 » R包shiny开发网页–5.shinydashboard的标题栏

评论 抢沙发

  • QQ号
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

学习、交流、分享

生信分析交流群综合科研交流群

登录

忘记密码 ?

切换登录

注册