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

From: Johannes Graumann <johannes_graumann_at_web.de>
Date: Tue, 05 Jul 2011 09:00:08 +0300


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 userexposed  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.


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 05 Jul 2011 - 06:05:47 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Jul 2011 - 17:40:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive