我希望每个页面都有一个侧边栏。
我不想在所有页面上都使用sidebar
,因为某些页面我不希望使用它。
这就是为什么我使用Inputs {.sidebar}
和Outputs
的原因。
但是,问题是在Second
页中,边栏没有反应。如果我更改日期范围,则绘图不会像第一页Intro
一样进行更新。
---
title: "Untitled"
author: "George"
date: "12/3/2018"
output:
flexdashboard::flex_dashboard
runtime: shiny
---
```{r global, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flexdashboard)
library(dplyr)
library(lubridate)
library(ggplot2)
dates <- c("01/01/18 1:00:00 PM" ,"01/01/18 1:01:00 PM",
"01/01/18 1:02:00 PM" ,"01/01/18 1:03:00 PM",
"01/01/18 1:04:00 PM" ,"01/01/18 1:05:00 PM",
"02/01/18 1:00:00 PM" , "02/01/18 1:10:00 PM",
"03/01/18 1:06:00 PM" ,"03/01/18 1:07:00 PM",
"03/01/18 1:08:00 PM" ,"03/01/18 1:09:00 PM",
"03/01/18 1:10:00 PM" ,"03/01/18 1:11:00 PM")
x <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
y <- c(11,22,33,44,55,66,77,88,99,100,111,112,113,114)
datfr <- data.frame(dates, x, y)
datfr$dates <- dmy_hms(datfr$dates)
```
Intro
========================================================================
Inputs {.sidebar}
--------------------------------------------------------------------
```{r}
dateRangeInput('dateSelect', 'Date Range', start = min(datfr$dates),
end = "2018-01-03", min = min(datfr$dates),
max = max(datfr$dates))
dateRange <- reactive({
datfr %>%
filter(dates >= input$dateSelect[1] & dates <= input$dateSelect[2])
})
```
Outputs
-----------------------------------------------------------------------
### Chart
```{r}
renderPlot({
ggplot(dateRange(), aes(x, y)) +
geom_point()
})
```
Column
------------------------------------------------------------
Hi thgere
Second
====================================================
Inputs {.sidebar}
--------------------------------------------------------------------
```{r}
dateRangeInput('dateSelect', 'Date Range', start = min(datfr$dates),
end = "2018-01-03", min = min(datfr$dates),
max = max(datfr$dates))
```
Outputs
-------------------------------------------------------------------
### Here
```{r}
df_by_day <- datfr %>%
dplyr::mutate(
new_x = (x + 10),
new_y = (y + 20),
)
dateRange2 <- reactive({
df_by_day %>%
filter(dates >= input$dateSelect[1] & dates <= input$dateSelect[2])
})
renderPlot({
ggplot(dateRange2(), aes(x, y)) +
geom_point()
})
```
Don't want sidebar here
==================================================
NO
答案 0 :(得分:0)
输入标识符必须唯一。
您可以将第二个dateRangeInput()
重命名为'dateSelect2'
,并在dateRange2 <- reactive({ ... ; input$dateSelect2 ; ... })
中相应地使用它。