[R] Help

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Feb 10 12:36:17 CET 2015


If it works interactively then as far as this mailing list is concerned it works. Executing in different environments such as a scheduler can affect any program, not just R, and the reasons are due to the operating system, not R.

In general, you should be aware of the configuration and resource requirements of R in general and your script in particular when switching execution environments.  You can learn more about what R depends on by reading the R-admin.pdf file that comes with R. Environment variables such as R_LIBS are common differences found between interactive and scheduled execution.
Another issue is permissions... scheduled execution often runs as a user who has different permissions than your interactive login does... but that is very off topic here.

One strategy you can try is creating a test script that just checks each requirement that you identify and logs what it finds, and then you can change either the way you are running the batch or add commands to the batch that configure things the way your script needs them. When the logs indicate things are set up right, you will know what to do to your actual processing script to make it work.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On February 9, 2015 9:07:24 PM EST, "Andrés Felipe Flórez Rivera" <afflorezr at unal.edu.co> wrote:
>Hi everyone,
>
>I am trying to automate (on a Win7 system) an R script to read data
>from a
>DB2 data base and write it to file, for processing by another system.
>My
>code runs in the R gui perfectly. So I wrote a batch file to call this
>.r
>file and output results to script.out as shown below. When I double
>click
>the batch file everything runs successfully. When I schedule a task to
>run
>the batch file, the R code runs, collects data from DB2 data base, but
>the
>write to file fails every time, only save the header from sql query.
>
>R Code:
>
>library(RJDBC)
>library(rJava)
>jcc = JDBC("com.ibm.db2.jcc.DB2Driver",".../db2jcc4.jar")
>conn = dbConnect(jcc,"xxx",user="xxxx",password="xxxx")
>bd1 = dbSendUpdate(conn, "set current schema PRODUCCION")
>bd1 = dbSendQuery(conn,
>paste("SELECT *
>FROM VW_tabla_1"))
>dat4<- fetch(bd1, n = -1)
>write.csv2(dat4,file = ".../bd1.csv",row.names = F)
>dbDisconnect(conn)
>
>
>batch file code:
>
>\Program Files\R\R-3.0.1\bin\x64\R.exe" CMD BATCH --vanilla --slave
>"C:\Users\abg\SkyDrive\Documents\dat.R"
>
>
>thanks.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list