I sincerely apologize but it has been a month now of trying but I still cannot figure out. The main question: How to use Shiny R to appear "run code" button in one page and then when pressed & finished calculating two new results in separate tabs/windows appear?
I have a code saved as "Button_test.R" with the following content:
long_code <- source("long_code.R")$value
library(shiny)
shinyApp(
  fluidPage(
    titlePanel("Test results"),
     actionButton("run", "run code")),
 function(input, output, session){
    vals <- reactiveValues()
     mainPanel(titlePanel("Test results"))
     fluidRow(
       column(12,
           dataTableOutput('table'),
     )
   )
observeEvent(input$run, {
  vals$long_code_out <- long_code()
  showModal(modalDialog("calculation finished!"))
  output$table <- renderDataTable(pred)
  stopApp()
   })
 }
)
The "long_code.R" file contains the following files (gasoline pls data -- available using pls package) and codes:
function(){
library(pls)
library(prospectr)
library(Metrics)
library(factoextra)
 
data(gasoline)
gasTrain <- gasoline[1:50,]
gasTest <- gasoline[51:60,]
gas1 <- plsr(octane ~ NIR, ncomp = 10, data = gasTrain, validation = 
"LOO")
pred <- predict(gas1, ncomp = 2, newdata = gasTest)
write.csv(pred,"pred.csv")
jpeg('pca.jpg')
plot(RMSEP(gas1), legendpos = "topright")
dev.off()
}
When I first run the "Button_test.R" it showed "run code" with the page below:
Then, when I pressed the "run code," the calculation was finished. However, I am interested to produce in 2 separates pages (new tabs or new windows) the results for "pca.jpg" plot and "pred" results similar below:
I am not sure how to do it and where do I put the code. I am sorry for this long code. It is just necessary to produce the results. My apologies.
 
    