我是rshiny的新手如何根据选定的值创建要素。在具有交付日期的数据中,根据UI中的日期选择("日期输入"(计算延迟天数,并为每个观察添加值为"准时"、"延迟"或"未来"的新功能。
我是rshiny&柔性仪表板。
---
title: "Demo"
social: menu
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
navbar:
- {title: "<i class='fa fa-info'></i> Report Based on date 05-01-2019", align: right}
---
# Add Date Picker for Generate report Based on It.
dateInput("RDate",
label = "Report Date",
value = "2019-05-01",
min = NULL,
max = NULL,
format = "yyyy-mm-dd",
startview = "month",
language = "en",
width = NULL
)
Raw_data_1 <-mutate(Raw_data_1, OT_Due_date = ifelse(Raw_data_1$DueDate >= input$RDate,"Future",
(ifelse(is.na(Raw_data_1$LastRcvd),
(ifelse((Raw_data_1$Received >=Raw_data_1$Ordered),"On Time","Late")),
ifelse((Raw_data_1$Received >=Raw_data_1$Ordered) &
(Raw_data_1$LastRcvd <= Raw_data_1$DueDate),"On Time","Late")))))
我对flexdashboard没有经验,但由于您使用的是闪亮的运行时,您必须以不同的方式处理数据。1( 输入$value修改的所有数据都必须在Reactive表达式中2( renderTable/renderPlot等必须专门调用渲染
这是最终为我工作的代码:
---
title: "Demo"
social: menu
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
navbar:
- {title: "<i class='fa fa-info'></i> Report Based on date 05-01-2019", align: right}
---
```{r global, include = FALSE}
### ADD HERE YOUR RAW DATA AND LIBRARIES
```
# Add Date Picker for Generate report Based on It.
```{r}
dateInput("RDate",
label = "Report Date",
value = "2019-05-01",
min = NULL,
max = NULL,
format = "yyyy-mm-dd",
startview = "month",
language = "en",
width = NULL
)
```
```{r}
Raw_data <- reactive({
Raw_data_1 <- mutate(Raw_data_1,
OT_Due_date = ifelse(Raw_data_1$DueDate >= input$RDate,
"Future",
ifelse(is.na(Raw_data_1$LastRcvd),
ifelse((Raw_data_1$Received >= Raw_data_1$Ordered),
"On Time",
"Late"
),
ifelse(Raw_data_1$Received >= Raw_data_1$Ordered &
Raw_data_1$LastRcvd <= Raw_data_1$DueDate,
"On Time",
"Late"
)
)
)
)
})
renderTable(Raw_data())
```{r}