On 19/11/2012 3:27 PM, Bush, Daniel P. DPI wrote:
No, that did not resolve the issue, but thanks for the suggestion.

Here's another possibility: your Sweave session may not be setting the same option defaults in startup code as your regular session. This one just bit me: I normally work with options(stringsAsFactors = FALSE), because I don't like to have strings automatically converted to factors. However, this option wasn't set when running Sweave externally.

Duncan Murdoch


Daniel Bush | School Finance Consultant
School Financial Services | Wis. Dept. of Public Instruction
daniel.bush -at- dpi.wi.gov | 608-267-9212


-----Original Message-----
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com]
Sent: Friday, November 16, 2012 1:51 PM
To: Bush, Daniel P. DPI
Cc: 'r-help@r-project.org'
Subject: Re: [R] Error in Sweave but not underlying script

On 16/11/2012 2:26 PM, Bush, Daniel P. DPI wrote:
> I'm trying to use Sweave to create a dynamic report of a variety of financial 
data checks. I have an .R code file to pull the data from a database, manipulate 
and filter it, and create individual data frames for each test. My Sweave .RNW 
document then calls that file with source() to generate the data for the report. 
The .R file works fine on its own, but when I run it from within the Sweave 
document I get the following error message:
>
> Error in .subset(x, j) : only 0's may be mixed with negative
> subscripts
>
> Again, the .R code works perfectly well on its own--I only get the error when 
calling it through Sweave. Is there some quirk to Sweave that certain functions 
don't work properly?

No, it's a pretty standard evaluation environment.  However,  it may be running R without 
some functions that exist in your workspace when you source the script within an R 
session.  It's also possible (but doesn't seem likely) that RStudio is causing some 
problems; you could try running "R CMD Sweave yourdoc.Rnw" from the command 
line, outside of Rstudio, to see if that makes a difference.

Duncan Murdoch
>
> I am using the built-in Sweave function within RStudio 0.97.168.
>
> DB
>
> Daniel Bush
> School Finance Consultant
> School Financial Services
> Wisconsin Department of Public Instruction PO Box 7841 | Madison, WI
> 53707-7841 daniel.bush -at- dpi.wi.gov | sfs.dpi.wi.gov
> Ph: 608-267-9212 | Fax: 608-266-2840
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to