TeraGrid.org Parent Organization Links

Running R via Condor (on Linux)

Running R via Condor (on Linux)

First, please be sure to read the General Instructions on Condor Use at Purdue. Having done that, here are some more specifics about dispatching R jobs to Linux machines in the Purdue Condor pool.

R is installed on all RCAC/Purdue Linux clusters in /apps/01/R-2.7.0/ and requires the argument "--vanilla" to work via Condor.

Here is a simple example R script:

#
# example.r
#
#
# Sorting Algorithm
# Courtesy of http://www.mayin.org/ajayshah/KB/R/index.html
#
# The approach here needs to be explained. If `i' is a vector of
# integers, then the data frame D[i,] picks up rows from D based
# on the values found in `i'.
#
# The order() function makes an integer vector which is a correct
# ordering for the purpose of sorting.

D <- data.frame(x=c(1,2,3,1), y=c(7,19,2,2))
D

# Sort on x
indexes <- order(D$x)
D[indexes,]

# Print out sorted dataset, sorted in reverse by y
D[rev(order(D$y)),]

To submit the above script via Condor, compose a Condor submission script such as the following. Use the "--vanilla" option to R in the Condor submission script to run R in Condor-compatibility mode:

#
# r.condor
#

executable = /apps/01/R-2.7.0/bin/R
arguments = --vanilla
universe = vanilla
getenv = true
requirements = ( ( ARCH == "X86_64" || ARCH == "INTEL") && OPSYS == "LINUX" )
input = example.r

should_transfer_files = yes
transfer_executable = false
when_to_transfer_output = ON_EXIT

log = r.log
output = r.out
error = r.err

queue

Submit this and check on its status using "condor_submit" and "condor_q" as described in the General Instructions on Condor Use at Purdue. Once the job is complete, you should have the expected output in the "r.out" file as specified above in the Condor submission script:

> #
> # example.r
> #
> #
> # Sorting Algorithm
> # Courtesy of http://www.mayin.org/ajayshah/KB/R/index.html
> #
> # The approach here needs to be explained. If `i' is a vector of
> # integers, then the data frame D[i,] picks up rows from D based
> # on the values found in `i'.
> #
> # The order() function makes an integer vector which is a correct
> # ordering for the purpose of sorting.
> 
> D <- data.frame(x=c(1,2,3,1), y=c(7,19,2,2))
> D
  x  y
1 1  7
2 2 19
3 3  2
4 1  2
> 
> # Sort on x
> indexes <- order(D$x)
> D[indexes,]
  x  y
1 1  7
4 1  2
2 2 19
3 3  2
> 
> # Print out sorted dataset, sorted in reverse by y
> D[rev(order(D$y)),]
  x  y
2 2 19
1 1  7
4 1  2
3 3  2
>