0

I want to compare the speed of matrix multiplication using different number of cores. I want to write a for loop on number of cores in shell code. But the actual computation is done in R. So it's a mix of bash shell code and R code. Something like the following

for p in {1..8}
do
    export OMP_NUM_THREADS = p

    ## R code for matrix multiplication ##

done

Is this possible to do?

1
  • There are numerous techniques to run an R script from the command line. I suggest you write an R script in a separate file, and call it from your bash script with Rscript --vanilla script.R. Commented Oct 23, 2013 at 0:51

1 Answer 1

1

Rscript is the command to do just that. Make you R script executable and put at the 1st line:

#!/usr/bin/env Rscript

After that, you can treat it as any other program in the system, calling it from bash and whatever else.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.