Dominic Comtois
Dominic Comtois

Reputation: 10411

R: Warning when building a package

In the package I'm writing, I have a "custom" print function for objects of class, say, "myclass".

print.myclass <- { 
  # ... 
  # ...
}

In the print.myclass.Rd file, I have something like this:

\name{print.myclass}
\alias{print.myclass}
\alias{print}
\title{Print method for objects of class \code{myclass}.}
\description{Display \code{myclass} objects in the console or in \emph{RStudio's Viewer}.}
\usage{
  \method{print}{myclass}(x, method, \dots)
  print(x, method="some.method", ...)
}

When I run the R CMD check --as-cran, I get the following warning:

* checking for code/documentation mismatches ... WARNING Functions or methods
with usage in documentation object 'print.summarytools' but not in code:   
print

I must have tried all the possible combinations of trial and error, importing this and erasing that, but I'm hiting a wall. I'm not even sure what "but not in code" means... Are we talking about the R code in the R scripts, or the code in the .Rd file?

I'm hoping someone who's had enough experience building packages could guide me towards the light.

Thx

Upvotes: 2

Views: 315

Answers (1)

Dominic Comtois
Dominic Comtois

Reputation: 10411

The solution is simply to remove the 2nd line in the \usage section:

\usage{
  \method{print}{myclass}(x, method, \dots)
  print(x, method="some.method", ...)        <- culprit
}

To keep the additionnal bit of information given in the second line (the default value for method, this works:

\usage{
  \method{print}{myclass}(x, method="some.method", \dots)
}

Upvotes: 1

Related Questions