Hello, good evening, I am trying to create a shiny app in which there are 2 text boxes where you enter dates and I filter the data by dates. Then I print you a result with the difference between two values, but I have not found a way to transform the functions to a Shiny app. I leave the code with the general idea of what I want to do in the app, in case someone has any idea to introduce these functions to a shiny app:
library(lubridate)
library(dplyr)
df <- data.frame(
fecha = seq(as.Date("1980-01-01"), as.Date("2020-05-31"), by = "quarter"),
datos = sample(c(1:100), size = 162, replace = TRUE)
)
dato1 <- df %>%
filter(fecha == "2019-07-01")
dato2 <- df %>%
filter(fecha == "2017-07-01")
x <- dato1$datos - dato2$datos
if( x < 0 ){
print(paste("Hubo una entrada de capitales por",abs(x),"millones de dólares"))
} else {
print(paste("Hubo una salida de capitales por",abs(x),"millones de dólares"))
}
Thanks for reading me