[R] Paths for Shell Scripts called from R

Fernando Henrique Ferraz P. da Rosa feferraz at ime.usp.br
Sat Dec 11 23:50:38 CET 2004


Damian Betebenner writes:
> Hello list,
> 
> I suspect this is more a linux question than an R question, but I'll describe my situation in case
> anyone here knows of an elegant solution.
> 
...
> My bash shell script uses a standard for loop to loop over all the .tex file in a directory
> 
> for f in *.tex
> 
> The problem that I'm having is that I can't seem to direct latexall to the correct subdirectory without placing
> latexall in the subdirectory with all the table.tex files and hard coding that subdirectory into the the shell 
> script before using the SYSTEM command to call latexall.
> 
> for f in /home/directory/subdirectory/tables/*.tex  
> 
> Does anyone have an idea of how I can pass the appropriate path to my shell script from within R?
> 

        You could use the $* argument in your bash script, and then pass
the argument via system(), on the call to the script. Suppose you have

$ cat pdflatexall.sh 
#!/bin/bash

for i in $1/*.tex; do
        echo pdflatex $i;
done

        In R you could call by using:

        system('pdflatexall.sh /tmp')

        Works fine here:

$ touch /tmp/bla1.tex /tmp/bla2.tex
$ R
> system('pdflatexall.sh /tmp')
pdflatex /tmp/bla1.tex
pdflatex /tmp/bla2.tex




--
Fernando Henrique Ferraz P. da Rosa
http://www.ime.usp.br/~feferraz




More information about the R-help mailing list