I have a text file created in my project directory .
FOr example. I have created a ui.R and server.R in my project directory. I have a small code that creates and appends some contents in text file, See below. But wanted to check if we can show the object "cs" that is created through try catch as soon as we open the app? I tried with the below code but failed. Can anyone help me here please.
So basically as soon as I open the number 8 should be seen on the screen (since cs <- 3 + 8
)
ui.R
library(shiny)
source("add.R")
# Define UI for application that draws a histogram
shinyUI(fluidPage(
textInput("name", "Name: "),
textOutput("greeting"),
actionButton("checkme","checkme"),
selectInput("Slider","Slider",choices = unique(iris$Species))
)
)
server.R
library(shiny)
source("add.R")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
myfileexists <- eventReactive(input$checkme,{
file.exists("test2.txt")
})
output$greeting <- renderText({
paste0("Hello, ", input$name, "Does your file exist ?", myfileexists())
})
print(getwd())
file.create("test2.txt")
write(cs,file="test2.txt",append=TRUE)
tryCatch({
showNotification(cs
)
})
})
add.R
a <- 3 + 4
cs <- 3 + 5