Windows批处理 - [R Sweave错误装包 [英] Windows batch R Sweave error loading packages

查看:168
本文介绍了Windows批处理 - [R Sweave错误装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到如何建立一个批处理文件,在Windows XP上一个Sweave文档清晰的文档。

我使用所发现的这里

我创建一个批处理文件名的run.bat 包含以下内容:

  Sweave myFile.Rnw

设置WD后,我在Sweave文件做的第一件事是使用 RODBC 包读取数据集:

 库(RODBC)
取< - odbcConnect(MYDATABASE)
myData的< - 从myTable的SELECT *
X'LT; - 类SqlQuery(读取,MYDATA的)
odbcCloseAll()

当我运行我的批处理文件,我收到以下错误:

 错误:2块
在库(RODBC)错误:没有呼包RODBC
另外:警告消息:
在库(包,lib.loc = lib.loc,character.only = TRUE,logical.return = TRUE,:
    没有包称为'xtable

显然,这些包确实存在,是功能性的,但东西是不正确的权限,或者没有找到合适的目录。有什么想法?

相关问题<一href=\"http://stackoverflow.com/questions/1188544/getting-windows-to-start-r-in-batch-mode-using-the-start-command\">here


解决方案

我发现一个立即解决我的问题,虽然知道有这种方法一定的局限性。我放弃使用CRAN动态寻求R和硬codeD的路径与R相应的路径提供.bat文件这样:

 C:\\ Program Files文件\\ r \\ R-2.11.0 \\ BIN \\ Rterm.exe--vanilla&LT;%run.r&GT;%run.r
 德尔* .LOG
 德尔·.aux

的.bat 文件将火起来R,运行脚本 run.r ,其中包含两个命令:

  Sweave(myFile.Rnw)
工具:: TEXI2DVI(myFile.tex,PDF格式= TRUE)

,然后清理从LaTeX的输出中间 .LOG .aux 文件。显然,工作散装 myFile.Rnw 做,但这将ATLEAST让我点击一个按钮,执行我的分析,并生成PDF文件。

如果有人能想办法使这种更有效的,我AP preciate它。

I am having trouble finding clear documentation on how to set up a batch file for a Sweave document on Windows XP.

I am using the batch files that are found here

I have created a batch file names run.bat which contains the following:

Sweave myFile.Rnw

The first thing I do in my Sweave file after setting the wd is read in a dataset using the RODBC package:

library(RODBC)
fetch <- odbcConnect("myDatabase")
myData <- "select * from myTable"
x <- sqlQuery(fetch, myData)
odbcCloseAll()

When I run my batch file, I receive the following error:

Error: chunk 2
Error in library(RODBC) : there is no package called RODBC
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called 'xtable'

Obviously these packages do exist and are functional, but something isn't right in the permissions or it isn't finding the right directories. Any thoughts?

Related question here

解决方案

I found an immediate solution to my problem, though understand there are certain limitations to this method. I abandoned using the CRAN provided .bat files for dynamically finding the appropriate path to R and hardcoded the path to R as such:

"C:\Program Files\R\R-2.11.0\bin\Rterm.exe" --vanilla <%run.r>%run.r
 del *.log
 del *.aux

This .bat file will fire up R, run the script run.r which contains two commands:

Sweave("myFile.Rnw")
tools::texi2dvi("myFile.tex", pdf=TRUE)

and then cleans up the intermediate .log and .aux files from the LaTeX output. Obviously, the bulk of the work is done in myFile.Rnw but this will atleast let me click one button, perform my analysis, and generate the PDF file.

If someone can think of a way to make this more efficient, I'd appreciate it.

这篇关于Windows批处理 - [R Sweave错误装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆