[R] Errors checking a library
Roger Bivand
Roger.Bivand at nhh.no
Thu Nov 18 15:26:34 CET 2004
On Thu, 18 Nov 2004, michael watson (IAH-C) wrote:
> Hi
>
> I am writing an R library. The documentation for one of my functions
> includes an example that I *know* works - simply cut and paste into R on
> either Windows and Linux and it works perfectly, no errors or warnings,
> nothing, nyet.
>
> However, when I run "R CMD check" on the library, I get an error. I am
> running R CMD check on linux, and the offending piece of code appears to
> be:
>
> cox[cox$group %in% onc,]
>
> "cox" is a data frame, one of the columns of which is group, which
> contains numbers. "onc" is a vector of numbers.
>
> The output on Linux from R CMD check is this:
>
> > # lots of code
> > # lots of code
> >cox[cox$group
> +
> +
> + # the rest of my code
> Error: syntax error
> Execution halted
>
> As can be seen, my code "cox[cox$group %in% onc,]" seems to have been
> executed incorrectly. Does R CMD check have a problem with the "%in%"
> operator? It would seem that R has somehow got mixed up and has lost
> the rest of my command.
I'm guessing at what you may mean, so excuse me getting it wrong. If the
code is in an example in a help file (*.Rd, \examples{} block), then the %
may be being interpreted as a comment character, and the remainder of the
line not processed - see Writing R Extensions -> Writing R documentation
files -> Insertions.
If that is the problem, then escaping the % by \% should fix it, that it
what is done in src/library/base/man/match.Rd anyway.
>
> I'm using R 1.9.1 on Suse Linux 8.2. The example code works fine on
> both Windows and Linux when cut-and-pasted into an R window.
>
> Mick
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list