So I wrote an R Shiny app that analyzes student loan information and recommends the best way to pay them down. A lot of people, including myself, have multiple student loans with different interest rates, so I made some conditionalPanel
s that show up based on how many student loans the user says they have. Each conditionalPanel
has numericInput
s for loan principal, interest rate, and how much the user wants to pay per month. It's a bit of a process for the user to enter all this data once, and unfortunately it all gets wiped out if the user navigates away from the page or refreshes it.
How can I save the session data so the user doesn't have to re-enter their information in numericInput
s every single time? I feel like the answer has something to do with accessing session
data, but I'm not really sure. Any help is appreciated. Thanks!
Here's an example of what goes on, on the UI side:
# Define UI for application
ui <- shinyUI(fluidPage(
# Application title
titlePanel("Student Loan Calculator"),
# Sidebar with nested sidebar panels containing numeric inputs to enter info about each loan.
sidebarLayout(
sidebarPanel(width = '3',
numericInput("numStuLoan",
"How many student loans do you have?",
min = 0,
max = 5,
value = 1,
step = 1),
HTML("<br>"),
#### #### #### #### ####
#### Loan 1 ## #### ####
#### #### #### #### ####
conditionalPanel(condition="input.numStuLoan > 0",
HTML("<div align = 'left'><font size = '4'><b>1st Loan</b></font></div>"),
numericInput("loanPrin1",
"Principal",
min = 0,
max = Inf,
value = 10000,
step = 50),
numericInput("loanInt1",
"Interest Rate",
min = 0.00,
max = 20.00,
value = 5.29,
step = 0.1),
numericInput("monthPay1",
"Monthly Payment",
min = 0.00,
max = Inf,
value = 250,
step = 1)),
HTML("<br>"),
...
...
...
{this code basically repeats for each loan}