-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.R
190 lines (184 loc) · 7.91 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
library(shiny)
library(plotly)
library(shinyWidgets)
library(DT)
library(shinydashboard)
library(shinyjs)
library(shinyBS)
dashboardPage(
dashboardHeader(title = "Retirement Calculator"),
dashboardSidebar(
sidebarMenu(id="sidebar",
menuItem("Introduction", tabName = "Introduction", icon = icon("comment-dollar")),
menuItem("Global Settings", tabName = "GlobalSettings", icon = icon("sliders-h")),
menuItem("FIRE Settings", tabName = "FIRESettings", icon = icon("sliders-h")),
menuItem("FIRE", tabName = "FIRE", icon = icon("chart-line")),
menuItem("Retirement Settings", tabName = "RetirementSettings", icon = icon("sliders-h")),
menuItem("Retirement", tabName = "Retirement", icon = icon("chart-area")),
menuItem("About", tabName = "About", icon = icon("question"))
)
),
dashboardBody(
shinyjs::useShinyjs(),
# https://stackoverflow.com/questions/44043475/adjust-size-of-shiny-progress-bar-and-center-it
# center Shiny progress bar in middle of screen
tags$head(
tags$style(
HTML(".shiny-notification {
height: 100px;
width: 800px;
position:fixed;
top: calc(50% - 50px);;
left: calc(50% - 400px);;
}"
)
)
),
tabItems(
tabItem(tabName = "Introduction",
tags$p("This is not intended to be fullproof and makes many assumptions, seek a financial professional for more in-depth individual advice."),
tags$br(),
actionButton('jumpToGlobalSettings', 'Next -> Global Settings')
),
tabItem(tabName = "GlobalSettings",
numericInput("age", "Current Age:", 35, min = 1, max = 78, step = 1),
numericInput("retirement_spending", "Yearly Retirement Spending ($):", 40000, min = 1, step = 1),
bsTooltip("retirement_spending", "How much money in todays dollars you expect to spend each year in retirement. This will be adjusted for inflation.", placement="right"),
fixedRow(
column(3,
numericInput("avg_stock_return_percentage", "Average Stock Return Percentage:", 8.1, min = 0.1, max = 100, step = 0.1),
bsTooltip("avg_stock_return_percentage", "The average stock market return. This along with the standard deviation creates the normal distribution to sample from.", placement="right")
),
column(3,
numericInput("stock_stddev", "Stock Return Percentage Standard Deviation:", 17, min = 0, max = 75, step = 0.1)
)
),
plotlyOutput("stock_histogram"),
fixedRow(
column(3,
numericInput("avg_bond_return_percentage", "Average Bond Return Percentage:", 2.4, min = 0.1, max = 100, step = 0.1),
bsTooltip("avg_bond_return_percentage", "The average bond return. This along with the standard deviation creates the normal distribution to sample from.", placement="right")
),
column(3,
numericInput("bond_stddev", "Bond Return Percentage Standard Deviation:", 7, min = 0, max = 75, step = 0.1)
)
),
plotlyOutput("bond_histogram"),
fixedRow(
column(3,
numericInput("avg_inflation_percentage", "Average Inflation Percentage:", 2, min = 0.1, max = 100, step = 0.1),
bsTooltip("avg_inflation_percentage", "The average inflation amount. This along with the standard deviation creates the normal distribution to sample from.", placement="right")
),
column(3,
numericInput("inflation_stddev", "Inflation Percentage Standard Deviation:", 4, min = 0, max = 75, step = 0.1)
)
),
plotlyOutput("inflation_histogram"),
tags$br(),
actionButton('jumpToFireSettings', 'Next -> FIRE Settings')
),
tabItem(tabName = "FIRESettings",
fixedRow(
column(3,
numericInput("brokerage_amount", "Brokerage Investments ($):", value = 50000, min = 0, step = 1),
bsTooltip("brokerage_amount", "How much you currently have invested via brokerage.", placement="right")
),
column(3,
uiOutput("stock_slider")
),
column(3,
uiOutput("bond_slider")
)
),
fixedRow(
column(3,
numericInput("income", "Yearly Income ($):", 60000, min = 1, step = 1),
bsTooltip("income", "Current yearly income after taxes.", placement="right")
),
column(3,
numericInput("spending", "Yearly Pre-Retirement Spending ($):", 45000, min = 1, step = 1),
bsTooltip("spending", "Current yearly spending after taxes.", placement="right")
),
column(3,
uiOutput("savings")
)
),
fixedRow(
column(3,
checkboxInput("rebalanceassets", "Rebalance brokerage asset allocation yearly", TRUE)
),
column(3,
uiOutput("target_stock")
),
column(3,
uiOutput("target_bond")
)
),
numericInput("income_growth_percentage", "Income Growth Percentage:", 1, min = 0, max = 100, step = 0.1),
bsTooltip("income_growth_percentage", "How much your yearly income will increase by each year as a percentage.", placement="right"),
uiOutput("retirementSpending"),
numericInput("target_withdrawl_percentage", "Target Withdrawl Rate Percentage:", 3, min = 0.1, step = 0.1),
bsTooltip("target_withdrawl_percentage", "How much will you withdraw each year during retirement? 3% is considered conservative.", placement="right"),
numericInput("avg_tax_rate_percentage", "Average Tax Rate Percentage:", 7, min = 0.1, max = 100, step = 0.1),
uiOutput("fire_target_ui"),
tags$br(),
actionButton('jumpToFire', 'Next -> FIRE')
),
tabItem(tabName = "FIRE",
downloadButton("downloadmontecarlo", "Download Monte Carlo Pre-Retirement Data"),
tags$h3("Sample of the first Monte Carlo run:"),
DT::dataTableOutput("montecarlo_table"),
plotlyOutput("brokerage_graph"),
plotlyOutput("hit_fire_target_graph"),
tags$br(),
actionButton('jumpToRetirementSettings', 'Next -> Retirement Settings')
),
tabItem(tabName = "RetirementSettings",
numericInput("retirementage", "Retirement Age:", 65, min = 1, max = 100, step = 1),
uiOutput("retirementyear"),
uiOutput("retirementSpendingDup"),
numericInput("retirementsavings", "Savings Upon Retirement ($):", 2000000, min = 1, step = 1),
bsTooltip("retirementsavings", "How much you saved and will live off of upon retirement.", placement="right"),
fixedRow(
column(3,
uiOutput("stock_current_slider")
),
column(3,
uiOutput("bond_current_slider")
)
),
fixedRow(
column(3,
uiOutput("target_stock_retirement")
),
column(3,
uiOutput("target_bond_retirement")
)
),
fixedRow(
column(3,
checkboxInput("useavglife", "Use average life expectancy data", TRUE)
),
column(3,
uiOutput("setupavglife")
)
),
tags$br(),
actionButton('jumpToRetirement', 'Next -> Retirement')
),
tabItem(tabName = "Retirement",
downloadButton("downloadmontecarloretirement", "Download Monte Carlo Retirement Data"),
tags$h3("Sample of the first Monte Carlo run:"),
DT::dataTableOutput("montecarlo_table_retirement"),
plotlyOutput("brokerage_retirement_graph"),
plotlyOutput("broke_graph"),
plotlyOutput("deceased_graph"),
tags$br(),
actionButton('jumpToAbout', 'Next -> About')
),
tabItem(tabName = "About",
tags$a(href="https://github.com/carlsonp/shiny-retirement-calc", "Source Code")
)
)
)
)