У меня есть два файла app.R
и LoanHealthv2.R
app.R имеет следующий код.Я принимаю noc
в качестве входного имени, которое мне нужно передать в качестве ввода в LoanHealthv2.R
файл и вычислить результаты, чтобы я мог использовать результаты LoanHealthv2.R
файла в этом приложении.
Также, как я могу сделать его реактивным, чтобы каждый раз, когда я выбираю другой noc
, он генерировал новые результаты?
########################## Ui function ################################
ui=fluidPage(
titlePanel("Loan Health"),
fluidRow(
selectInput("noc","Name of Customer", customers[,1], selected = NULL, multiple = FALSE,
selectize = TRUE, width = NULL, size = NULL)
),
mainPanel(
plotOutput("Plot", width = "100%", height = "400px", click = NULL,
dblclick = NULL, hover = NULL, hoverDelay = NULL,
hoverDelayType = NULL, brush = NULL, clickId = NULL,
hoverId = NULL, inline = FALSE)
)
)
########################## server function ################################
server <- function(input, output) {
output$Plot<-renderPlot({
customer<-input$noc #Name of customer
plot(SalesClientData$Date,SalesClientData$DPD,type="l")
})
}
shinyApp(ui, server)
LoanHealthv2.R
выглядит так
customer = "A1" #<-I want this to be equal to input `noc` from app.R and compute the result below and make it available so that I can plot output.
account<-customers[which(customers[,1]==customer), 2]
start<- customers[which(customers[,1]==customer), 3]
SalesClientData = subset(POSData,POSData$Loan_Account_Number==account)