par<-tibble::tribble(
~fecha, ~`3X1`,
"27/04/2020", 0.047757121,
"28/04/2020", 0.046469264,
"29/04/2020", 0.045594935,
"30/04/2020", 0.046422991,
"04/05/2020", 0.046384532,
"05/05/2020", 0.046285446,
"06/05/2020", 0.04542063,
"07/05/2020", 0.043825089,
"08/05/2020", 0.042658616,
"11/05/2020", 0.044523176,
"12/05/2020", 0.043061725,
"13/05/2020", 0.044521232,
"14/05/2020", 0.044438627
)
colnames(par)<-c("fecha","3X1")
par$fecha<-as.character(par$fecha)
par$fecha<-as.Date(par$fecha,format="%d/%m/%Y")
par<-as.data.frame(par)
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Example"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
dateInput(
inputId = "ini",
label = "Selecciona la fecha de valoración:",
value = "2020-05-13"
)
),
# Show a plot of the generated distribution
mainPanel(
verbatimTextOutput( #inprime un dato en formato de codigo
outputId = "f")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
ini <-reactive(input$ini) #fecha seleccionada "YYYY-MM-dd"
ppf <-28
pila<-"3X1"
indi<-0
conv<-360
tiie<-function(datos,pilar,inicio,convencion,indicadora,plazopagos){
renglon<-which(datos$fecha==inicio)
}
fdesc <-tiie(datos = par,pilar=pila,inicio = ini,convencion = conv, indicadora = indi, plazopagos = ppf)
output$f<-fdesc
}
# Run the application
shinyApp(ui = ui, server = server)
The problem is:
Error in ==.default (datos$fecha, inicio) :
comparison (1) is possible only for atomic and list types
I think that the problem is in the line:
which(datos$fecha==inicio)
With: output$f<-fdesc I try to visualize the result of the function, but I don't know if this the best way to do that. Only that matter is make the function works in a shiny environment.
Thank you for all!