"michael watson (IAH-C)" <[EMAIL PROTECTED]> writes: > I am writing an R library.
A whole library? Shouldn't you try a package first? > 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. Think: What is the comment character in .Rd files? Checking out src/library/base/man/match.Rd should be enlightening, but since you might not have R sources installed, here are the relevant bits: \name{match} \alias{match} \alias{\%in\%} \title{Value Matching} \description{ \code{match} returns a vector of the positions of (first) matches of its first argument in its second. \code{\%in\%} is a more intuitive interface as a binary operator, which returns a logical vector indicating if there is a match or not for its left operand. } \usage{ match(x, table, nomatch = NA, incomparables = FALSE) x \%in\% table } .... \examples{ ## The intersection of two sets : intersect <- function(x, y) y[match(x, y, nomatch = 0)] intersect(1:10,7:20) 1:10 \%in\% c(1,3,5,9) sstr <- c("c","ab","B","bba","c","@","bla","a","Ba","\%") sstr[sstr \%in\% c(letters,LETTERS)] "\%w/o\%" <- function(x,y) x[!x \%in\% y] #-- x without y (1:10) \%w/o\% c(3,7,12) } \keyword{manip} -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html