[R] running R script on linux server
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Oct 12 13:41:47 CEST 2010
On 12.10.2010 00:55, Lorenzo Cattarino wrote:
> Hi R-users,
>
>
>
> I have a problem running my R code on a Linux cluster. What I did was
> write a .pbs file to instruct the cluster on what to do and how:
>
>
>
> #!/bin/sh
>
>
>
> #PBS -m ae
>
> #PBS -M uqlcatta at uq.edu.au
>
> #PBS -A uq-CSER
>
> #PBS -N job1_lollo
>
> #PBS -l select=1:ncpus=1:NodeType=fast:mem=8GB
>
> #PBS -l walltime=999:00:00
>
>
>
>
>
> cd $PBS_O_WORKDIR
>
>
>
> source /usr/share/modules/init/bash
>
>
>
> module load R/2.11.1
>
>
>
> /home/uqlcatta/script/diag.sh
>
>
>
> The .pbs file calls a .sh file, which is located on my home directory on
> the cluster, and which contains the R script (enclosed in " ") to run
>
>
>
> #!/bin/bash
>
>
>
> echo " mat<- matrix(1:12,nrow=3,ncol=4)
>
>
>
> diagonal<- diag(mat)
>
>
>
> write.csv(diagonal, file = "diagonal.csv")
>
>
>
> "> R_tmp
>
>
>
> echo 'source("R_tmp")' | R --vanilla --slave
>
> rm R_tmp
>
>
>
> However the cluster sends back to me an error message saying:
>
>
>
> Error in write.table(diagonal, file = diagonal.csv, col.names = NA, sep
> = ",", :
>
> object 'diagonal.csv' not found
>
> Calls: source ... write.csv -> eval.parent -> eval -> eval ->
> write.table
>
> Execution halted
>
>
>
> The write.csv command worked on the R consol on my computer, so I don't
> know what is the problem here.
You use double quotes inside double quotes. You either have to escape
them or use single quotes (if the shell permits the distinction).
Uwe Ligges
>
>
> Thanks in advance for your help
>
>
>
> Lorenzo
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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