Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Objects in \usage without \alias in documentation object from R CMD Check

I have written a small package for my own use, and using devtools everything has gone very well. However, I tried to run R CMD Check on it, and got a number of errors, seemingly because my usage and examples use functions from base R that aren't in my package, for instance here's my minimal function, and roxygen documentation

#' Function to Sort a dataframe with a given list of columns
#' Cribbed from Spector, P. (2008). "Data Manipulation with R", UseR! Springer. Pg78
#' @param df Dataframe to be sorted
#' @param ... list of columns to sort on
#' @return A sorted dataframe
#' @author "Paul Hurley"
#' @export
#' @usage with(dataframe,sortframe(dataframe,column1, column2, column3))
#' @examples with(iris,sortframe(iris,Sepal.Length,Sepal.Width,Petal.Length))
sortframe<-function(df,...){df[do.call(order,list(...)),]}

and R CMD Check gives

Undocumented arguments in documentation object 'sortframe'
  'dataframe' 'sortframe(dataframe, column1, column2, column3)'
Documented arguments not in \usage in documentation object 'sortframe':
  'df' '...'
Objects in \usage without \alias in documentation object 'sortframe':
  'with'

Is there a way to tell R CMD Check / roxygen2 that these functions are described in base ?

like image 559
PaulHurleyuk Avatar asked Mar 05 '13 10:03

PaulHurleyuk


1 Answers

You shouldn't include a @usage tag. Roxygen will infer it from your code. your @usage is really an example. R is complaining because you are referring to objects that aren't in your function definition at all. @usage, if you insist on putting it in yourself, should only reference sortframe, df, and .... Since you already have an @example, you should be able to omit the @usage tag.

like image 88
BrodieG Avatar answered Oct 11 '22 18:10

BrodieG