Dear all,
EDIT: had to retag this, because, it's rather a Sweave / R question since the problem of this script is the output directory of the Sweave Code. Is there a corresponding option for R CMD Sweave ?
I have a shell script that creates a .tex file from a .Rnw file. This file needs to be processed further, but is not found by the script because it's somehow automatically generated to my Home directory.
I need the .tex file to be generated in the folder of the .Rnw file (because all the other information is there). Note that the .Rnw file is what's usually selected with the file selector.
Side question: Is there an option for choose file, similar to JFileChooser in Java that enables only certain files for selection?
Here's the code:
#!/bin/bash
myfile=$(/usr/bin/osascript << EOT
tell app "AppleScript Runner"
activate
return posix path of (choose file)
end
EOT)
if [ $? -eq 0 ]
then
R CMD Sweave $myfile
no_ext="${myfile%.*}"
/usr/local/texlive/2009/bin/universal-darwin/pdflatex $no_ext.tex
open $no_ext.pdf
else
echo "User canceled"
fi
Thx, to all those who helped with this initial script!