[R-pkg-devel] A problem with Sweave in developing a package vignette

Duncan Murdoch murdoch.duncan at gmail.com
Sat Nov 25 02:29:38 CET 2017


On 24/11/2017 12:34 PM, Magnus Peterson wrote:
> I am using Sweave to create a vignette for a package,
> but when it appears in a code chunk of the .Rnw file
> the following line causes an execution halt of Sweave:-
> 
> data("WingPoints",envir = environment(()))
> 
> This is surprising since this data call as a line
> of a function within the package is accepted  by R
> and is indeed part of the "Best practice" recommendations
> in ?data called from R.

That's not legal syntax, so I'm not sure why you think it is accepted by 
R.  I see this when I try to run that:

 > data("WingPoints",envir = environment(()))
Error: unexpected ')' in "data("WingPoints",envir = environment(()"

> 
> What Sweave apparently objects to is the first closing
> inner bracket, indicating an empty inner argument for
> the variable environment.

No, since it is not legal syntax, it doesn't indicate anything at all.


> 
> Is this a bug or what should I do?  The function runs perfectly
> in R in its usual context, and in the .Rnw file it is in a  chunk
> headed

It's a bug in your code.  I don't know if this is what you are trying to 
do, but this would be legal syntax:

   data("WingPoints",envir = environment())

Duncan Murdoch



More information about the R-package-devel mailing list