[Rd] Circumventing code/documentation mismatches ('R CMD check')

Johannes Graumann johannes_graumann at web.de
Tue Jul 5 08:00:08 CEST 2011


Hello,

As prompted by B. Ripley (see below), I am transfering this over from R-User 
...

For a package I am writing a function that looks like

test <- function(Argument1=NA){
	# Prerequisite testing
	if(!(is.na(Argument1))){
		if(!(is.character(Argument1))){
			stop("Wrong class.")
		}
	}
	# Function Body
	cat("Hello World\n")
}

Documentation of this is straight forward:

...
\usage{test(Argument1=NA)}
...

However writing the function could be made more concise like so:

test2 <- function(Argument1=NA_character_){
	# Prerequisite testing
	if(!(is.character(Argument1))){
		stop("Wrong class.")
	}
	# Function Body
	cat("Hello World\n")
}

To prevent confusion I do not want to use 'NA_character_' in the user-
exposed documentation and using 

...
\usage{test2(Argument1=NA)}
...

leads to a warning reagrding a code/documentation mismatch.

Is there any way to prevent that?

Sincerely, Joh

Prof Brian Ripley wrote:

> On Mon, 4 Jul 2011, Johannes Graumann wrote:
> 
>> Hello,
>>
>> I'm writing a package am running 'R CMD check' on it.
>>
>> Is there any way to make 'R CMD check' not warn about a missmatch between
>> 'NA_character_' (in the function definition) and 'NA' (in the
>> documentation)?
> 
> Be consistent ....  Why do you want incorrect documentation of your
> package?  (It is not clear of the circumstances here: normally 1 vs 1L
> and similar are not reported if they are the only errors.)
> 
> And please do note the posting guide
> 
> - this is not really the correct list
> - you were asked to give an actual example with output.



More information about the R-devel mailing list