Deploying Shiny app automatically using Batch file

532 views
Skip to first unread message

Ted Hwang

unread,
Apr 24, 2017, 10:00:29 AM4/24/17
to Shiny - Web Framework for R
#------------------------------- Shiny Update
  library(rsconnect)
  library(data.table)
  library(xts)
  
  adj.or.not.vec <- c(TRUE,FALSE)
  
  #--------------- pair case
  for(adj.or.not in adj.or.not.vec){
    
    setwd(shiny.data.dir)
    saveRDS(adj.or.not,"adj.or.not.RDS")
    
    setwd(shiny.pairs.dir)
    source("Shiny.Main.R")
    setwd(shiny.pairs.dir)
    
    if(adj.or.not==TRUE){deployApp(appName = "traded_pairs",appTitle = "My Application")
    }else{
      deployApp(appName = "traded_pairs_raw",appTitle = "My Application")
      
    }
    
  }
 

Hi, the attached code runs well in RStudio, but when executed by a 'BAT' file with the following code, it fails to run. 

@echo off
"C:\Program Files\R\R-3.3.3\bin\R.exe" CMD BATCH --vanilla --slave "Y:\Archived Shared Drive\Ted Codes\Equities.Pairs.Trading.System\main.2.R"


I update my Shiny app on a daily basis as I process updated prices coming from the data source, and the input stocks we are interested in can change on a daily basis.

Any suggestions or advice are appreciated.

Thanks.  



Joe Cheng [RStudio]

unread,
Apr 24, 2017, 11:29:35 AM4/24/17
to Shiny - Web Framework for R
What's shiny.data.dir? And what error or output do you get?

Ted Hwang

unread,
Apr 24, 2017, 1:12:50 PM4/24/17
to Shiny - Web Framework for R

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric


Attaching package: 'xts'

The following objects are masked from 'package:data.table':

    first, last

Preparing to deploy application...DONE
Uploading bundle for application: 170185...Error in contrib.url(repos, type) : 
  trying to use CRAN without setting a mirror
Calls: deployApp ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

The above is the output I get after running the BAT file. Shiny.data.dir is a directory path ("character") well defined before the code I attached in the original post, and Shiny.Main.R is a program that should be run before app.R runs. The end part of Shiny.Main.R ends with setwd(Shiny Apps directory with 'app.R'). Any advice, please? Thanks. 
Reply all
Reply to author
Forward
0 new messages