繁体   English   中英

如何更改R CMD Sweave的输出目录?

[英]How can I change the output directory of R CMD Sweave?

使用R CMD Sweave总是在我的HOME目录中生成.tex文件。 有可能改变吗? 我的意思是我可以用shell脚本来制作它,但是我想有一些更好的技巧可以做到这一点

@Dirk:我使用了我在此处发布的脚本,而pdflatex找不到该文件,因为它总是写入用户的HOME目录。

?? 它始终在当前工作目录中 所以尝试

 mkdir foo
 mv whatever.Rnw foo
 cd foo
 R CMD Sweave whatever.Rnw

whatever.tex现在将是~/foo因为这是您a)放置源代码和b)调用命令的地方。

所以这是对我有用的... R CMD Sweave没有论据,但仍然是一种解决方法。 使用basename和dirname很有帮助:)

#!/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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM