Windows R Sweave Package Download Packages

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

I use batch files that are found here

I created run.bat batch file run.bat that contain the following:

 Sweave myFile.Rnw 

The first thing I do in the Sweave file after installing wd is to read in the dataset using the RODBC package:

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

When I run the batch file, I get 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 exist and are functional, but something is wrong in the permissions or it does not find the necessary directories. Any thoughts?

Related question here

+2
source share
2 answers

I found an immediate solution to my problem, although I understand that there are certain limitations to this method. I refused to use the .bat files provided by CRAN to dynamically find a suitable path to R and hard-coded 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 run R, run script run.r , which contains two commands:

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

and then cleans the intermediate .log and .aux from LaTeX. Obviously, the bulk of the work is done in myFile.Rnw , but this will at least allow me to click on a single button, perform my analysis and create a PDF file.

If anyone can think about how to make this more efficient, I would appreciate it.

+1
source

What does this return when you type it in R (in the GUI)?

  .libPaths() 

What does it show when run in an rnw file?

The documentation in help(Startup) will have a few suggestions as to where you can install R_LIBS and its variants.

+1
source

All Articles