我正在尝试使用runtime: shiny
将交互式瀑布图添加到我的flexdashboard中。抵押功能返回aDFmonth
数据帧,但是我不确定如何使其具有反应性,因此,每当用户更改输入月份时,每月的本金都会更新。您将在用户更改月份输入时随时分享有关如何使值-aDFmonth$Monthly_Principal[input$month]
更新的任何见解。
---
title: "My Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r}
library(flexdashboard)
library(dplyr)
library(latticeExtra)
library(waterfall)
library(tibble)
```
Sidebar {.sidebar}
-----------------------------------------------------------------------
```{r}
# Input vars
# home value
numericInput(inputId = "home.value", label = "Home value", value = 200000, step = 5000
)
# Month
numericInput(inputId = "month", label = "Month", value = 1, step = 1, min = 1, max = 360
)
```
```{r, include=FALSE}
# Update data
# monthly amortization
source("http://faculty.ucr.edu/~tgirke/Documents/R_BioCond/My_R_Scripts/mortgage.R")
reactive({
mortgage(P=input$home.value, I=4.5, L=30, amort=T, plotData=F)
})
# create dataframe
wf.df <- reactive({
tribble(
~label, ~value,
"(1) Rental Revenue", 1400,
"Principal", -aDFmonth$Monthly_Principal[input$month], # how can you make this reactive?
"Taxes", -100,
"Insurance", -100
)
})
```
## Column
```{r}
# render plot
renderPlot({
asTheEconomist(
waterfallchart(value ~ label, data=wf.df(),
main="Projected Cashflow")
)
})
```