问题描述
我想制作一个dasboard,第一行有一些BoxValues,第二行有一个图形。我关注了this guide,因此必须将其生成:
---
title: "Untitled"
author: "John Doe"
date: "5/10/2020"
output:
flexdashboard::flex_dashboard
---
```{r setup,include=FALSE}
library(plotly)
library(flexdashboard)
knitr::opts_chunk$set(echo = FALSE)
```
Sobremortalidad
==============================
Row {data-width=150}
-----------------------------------------------------------------------
### Esta es una prueba
```{r}
valueBox(100,icon="fa-bolt",color="red")
```
### Comments per Day
```{r}
valueBox(80,icon = "fa-comments")
```
### Comments per Day
```{r}
valueBox(50,icon = "fa-death")
```
Row
-----------------------------------------------------------------------
### Some random data
```{r}
month <- c('January','February','march','April','May','June','July','August','September','October','November','December')
high_2000 <- c(32.5,37.6,49.9,53.0,69.1,75.4,76.5,76.6,70.7,60.6,45.1,29.3)
low_2000 <- c(13.8,22.3,32.5,37.2,56.1,57.7,58.3,51.2,42.8,31.6,15.9)
high_2007 <- c(36.5,26.6,43.6,52.3,71.5,81.4,80.5,82.2,76.0,67.3,46.1,35.0)
low_2007 <- c(23.6,14.0,27.0,36.8,47.6,58.9,61.2,53.3,48.5,31.0,23.6)
high_2014 <- c(28.8,28.5,37.0,56.8,69.7,79.7,78.5,77.8,74.1,62.6,45.3,39.9)
low_2014 <- c(12.7,14.3,18.6,35.5,58.0,60.0,58.6,51.7,45.2,32.2,29.1)
data <- data.frame(month,high_2000,low_2000,high_2007,low_2007,high_2014,low_2014)
#The default order will be alphabetized unless specified as below:
data$month <- factor(data$month,levels = data[["month"]])
fig <- plot_ly(data,x = ~month,y = ~high_2014,name = 'High 2014',type = 'scatter',mode = 'lines',line = list(color = 'rgb(205,12,24)',width = 4))
fig <- fig %>% add_trace(y = ~low_2014,name = 'Low 2014',line = list(color = 'rgb(22,96,167)',width = 4))
fig <- fig %>% add_trace(y = ~high_2007,name = 'High 2007',width = 4,dash = 'dash'))
fig <- fig %>% add_trace(y = ~low_2007,name = 'Low 2007',dash = 'dash'))
fig <- fig %>% add_trace(y = ~high_2000,name = 'High 2000',dash = 'dot'))
fig <- fig %>% add_trace(y = ~low_2000,name = 'Low 2000',dash = 'dot'))
fig <- fig %>% layout(title = "Average High and Low Temperatures in New York",xaxis = list(title = "Months"),yaxis = list (title = "Temperature (degrees F)"))
fig
```
请注意,我需要连续三个valueBox,然后在第二行中显示图形。
我该如何实现?
解决方法
您必须将flexdashboard的方向设置为rows
。参见here:
---
title: "Untitled"
author: "John Doe"
date: "5/10/2020"
output:
flexdashboard::flex_dashboard:
orientation: rows
---