我正在使用R语言和Visual Studio 2017.我正在尝试使用Flexdashboard http://rmarkdown.rstudio.com/flexdashboard/index.html
为我的R脚本创建仪表板刚开始我想创建一个valueBox并在其中显示今天的日期。这是我的.rmd文件
---
title: "Dashboard v1"
output: flexdashboard::flex_dashboard
---
```{r setup, include=FALSE}
library(flexdashboard)
```
### Todays Date
```{r}
today <- Sys.Date()
valueBox(today, icon = "lock")
```
当我在Visual Studio 2017中运行文件时,值框不会显示,只显示日期。请看下面的截图。
我很感激任何帮助。
感谢。
答案 0 :(得分:1)
我认为像“valueBox”和“infoBox”这样的盒子对象是shinydashboard函数,并使用shinyboard css和javascript来显示这些框。
这是我通过在块中插入shinydashboard应用程序来在Rmarkdown中运行框的方式:
---
title: "Dashboard v1"
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
```
```{r}
library(shinydashboard)
today <- Sys.Date()
ui <- dashboardPage(
dashboardHeader(disable = TRUE),
dashboardSidebar(disable = TRUE),
dashboardBody(
fluidRow(
# A static valueBox
valueBox(today, "New Orders", icon = icon("credit-card")),
# Dynamic valueBoxes
valueBoxOutput("progressBox"),
valueBoxOutput("approvalBox")
)
)
)
server <- function(input, output) {
output$progressBox <- renderValueBox({
valueBox(
paste0(25 + input$count, "%"), "Progress", icon = icon("list"),
color = "purple"
)
})
output$approvalBox <- renderValueBox({
valueBox(
"80%", "Approval", icon = icon("thumbs-up", lib = "glyphicon"),
color = "yellow"
)
})
}
shinyApp(ui, server)
```