【问题标题】:Problem with Rows an Columns in Flexdashboard RFlexdashboard R中的行列问题
【发布时间】:2020-10-05 21:29:38
【问题描述】:

我想在顶行制作一个带有一些 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, 49.9, 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, 57.7, 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, 49.9, 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', line = list(color = 'rgb(205, 12, 24)', width = 4, dash = 'dash')) 
fig <- fig %>% add_trace(y = ~low_2007, name = 'Low 2007', line = list(color = 'rgb(22, 96, 167)', width = 4, dash = 'dash')) 
fig <- fig %>% add_trace(y = ~high_2000, name = 'High 2000', line = list(color = 'rgb(205, 12, 24)', width = 4, dash = 'dot')) 
fig <- fig %>% add_trace(y = ~low_2000, name = 'Low 2000', line = list(color = 'rgb(22, 96, 167)', width = 4, 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
```

这是我的结果:

请注意,我需要三个 valueBoxes 在一行中,然后在第二行中的图形。

我怎样才能做到这一点?

【问题讨论】:

    标签: r r-markdown flexdashboard


    【解决方案1】:

    您必须将 flexdashboard 的方向设置为 rows。见here

    ---
    title: "Untitled"
    author: "John Doe"
    date: "5/10/2020"
    output: 
      flexdashboard::flex_dashboard:
        orientation: rows
    ---
    

    【讨论】:

    猜你喜欢
    • 2021-12-10
    • 2020-11-04
    • 2019-03-24
    • 2017-09-24
    • 2021-10-28
    • 2020-04-03
    • 2021-11-21
    • 2021-04-29
    • 2018-05-28
    相关资源
    最近更新 更多