내 할부 상환 테이블의 길이를 조정하고 싶습니다. 문제는 응용 프로그램과 해당 수식 (예 : 계산 기간 20 회)을 처음 실행할 때, 다음 실행에서 10 개의 기간을 실행해야하는 경우 수식이 이전에 계산 된 값을 유지하면서 계산을 덮어 쓰는 경우입니다.반짝이는 앱에서 동적 테이블 길이 조정 - R
샤인 코드는이 :
#ui.r
library(shiny)
shinyUI(
fluidPage(
titlePanel("Fondo de Amortización"),
sidebarLayout(
sidebarPanel(numericInput(inputId = 'M',label = 'Monto',value = 2400000),
numericInput(inputId = 'n',label = 'Período',value = 20),
numericInput(inputId = 'i',label = 'Interés',value = 3.7)),
mainPanel(
tableOutput('x')))
))
#server.r
library(shiny)
shinyServer(function(input, output, session) {
options(digits = 7)
options(scipen = 999)
IR <<- numeric();CA <<- numeric();SF <<- numeric()
f.amort <- function(M,i,n) {
R <<- M*i/(((1 + i)**n)-1)
IR[1] <<- 0
IR[2] <<- R*i
CA[1] <<- R
SF[1] <<- R
for (k in 1:(n-1)) {
CA[k+1] <<- R + IR[k+1]
SF[k+1] <<- SF[k] + CA[k+1]
if (k < n-1){
IR[k+2] <<- SF[k+1]*i
}
}
}
output$x <- renderTable({
f.amort(input$M, input$i/100, input$n)
tabla <- rbind((cbind("Rent" = c(R, recursive=TRUE),
(cbind("I" = IR, "Acumulado" = CA,
"BaC" = SF)))),
c(R*input$n,sum(IR),
sum(CA),000))
})
})
나는 테이블의 생성을위한 계산을 이해하지만, 샤이니에 동적으로 재생하는 순간에, 나는 그것의 길이의 수를 조정할 수 없습니다 미문. https://github.com/pakinja/-Financial-Mathematics-in-R/blob/master/AmortizationFund.r#L40