How can I change the output directory of R CMD Sweave?
Using R CMD Sweave my .tex file is always generated in my HOME directory. Is it possible to change this? I mean i could mv it with a shell script, but I guess there`s some better trick to do it
@Dirk: I used the script that I posted here and pdfl开发者_开发知识库atex does not find the file because it's always written to the HOME directory of my user.
Huh? It's always in the current working directory. So try
mkdir foo
mv whatever.Rnw foo
cd foo
R CMD Sweave whatever.Rnw
and whatever.tex
will now be ~/foo
because that is where you a) put the source and b) invoked the command.
So here's what worked for me... No argument for R CMD Sweave but still a workaround. the use of basename and dirname helped a lot :)
#!/bin/bash
myfile=$(/usr/bin/osascript << EOT
tell app "AppleScript Runner"
activate
return posix path of (choose file)
end
EOT)
if [ $? -eq 0 ]
then
echo $myfile
R CMD Sweave $myfile
no_ext=`basename $myfile .Rnw`
directory=`dirname $myfile`
mv ~/$no_ext.tex $directory/$no_ext.tex
/usr/local/texlive/2009/bin/universal-darwin/pdflatex -output-directory $directory $no_ext.tex
open $directory/$no_ext.pdf
else
echo "User canceled"
fi
精彩评论