I have one Rscript that I want to run on 100 files in a directory, I am creating a .sh file in bash to do this.
Rscript run_data.R <inputfile> <outputroot>
But rather than one input file I need to create a script that will loop the Rscript through 100 files I have in a directory.
I have tried this:
#!/bin/bash
#
#
#PBS -t 0-99
#PBS -l nodes=1:ppn=2,walltime=200:00:00
# Change into working directory
# Execute code
#Set -e allows you to test the script
set -e
echo "Running on ${HOSTNAME}"
if [ -n "${1}" ]; then
echo "${1}"
PBS_ARRAYID=${1}
fi
i=${PBS_ARRAYID}
files=("/mydirectory/")
echo ${files[$i]}
output=${output[$i]}
Rscript run_data.R ${files[$i]} ${output[$i]}
But this doesn't seem to be working, it says Execution halted
and will not run the Rscript.
Any suggestions would be amazing
Thanks!