0

Despite a lot of documentation and questions that I have already read in this forum, I still haven't been able to properly document my S3 generics. My code works, and I have successfully used my package, and even successfully tested it with friends. I am using Roxygen2 in linux, here is my session info:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=en_US.UTF-8          
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8           LC_ADDRESS=en_US.UTF-8       
[10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DiversityOccupancy_1.0.0

Here I send one of the most simple generics I have:

#' @param x a modeldiversity object which is a result from the modeldiversity
#' function
#' @examples
#' \dontrun{
#' data("BatOccu")
#' data("Dailycov")
#' data("sampling.cov")
#' x <-diversityoccu(pres = BatOccu, sitecov = sampling.cov, obscov = Dailycov,
#' spp = 17, form = ~ Julian + Meanhum + Meantemp + sdhum + sdtemp ~
#' Burn.intensity.soil + I(Burn.intensity.soil^2) + Burn.intensity.Canopy +
#' I(Burn.intensity.Canopy^2) + Burn.intensity.basal +
#' I(Burn.intensity.basal^2))
#' y <- model.diversity(x, method = "g", squared = TRUE)
#' summary(y)
#' }
#' @export
summary <- function(x, ...){
UseMethod("summary")
}
#' @rdname summary
#' @export
#' @method summary modeldiversity
#' @seealso \code{\link[DiversityOccupancy]{diversityoccu}}
#' @author Derek Corcoran <derek.corcoran.barrios@gmail.com>

summary.modeldiversity <- function (x, ...) {
  x$Table
  }

the warnings I get are the following:

Undocumented arguments in documentation object 'summary' ‘...’ Duplicated \argument entries in documentation object 'summary': ‘x’

But so far everywhere I have read tells me that is a good thing to put the ... after your function.

The second problem with the duplicated x

goes away if I remove the

summary <- function(x, ...){
UseMethod("summary")
}

But then I get warnings for not properly documenting s3 methods, anyone knows the solution for this?

Thanks

Derek Corcoran
  • 3,930
  • 2
  • 25
  • 54
  • 1
    you shouldnt be defining summary again. and try object instead of x – rawr Feb 27 '16 at 16:00
  • @rawr sorry if I don't understand completely, I tried in my second funcion (summary.modeldiversity) changing x by model, a while ago, but it gave me more errors, could you please show me with an example what do you mean Thanks for the quick reply – Derek Corcoran Feb 27 '16 at 16:14
  • 1
    You also have to document `...` by adding `@param ... something`. – Stibu Feb 27 '16 at 16:15
  • Thanks @Stibu that worked great, I still don't understand the duplicated x part – Derek Corcoran Feb 27 '16 at 16:22
  • 1
    The generic for `summary()` is already defined in the base package, so you should not define it again. And since you need to use the same variable names as the generic, you should use `object` for the first argument, not `x` (as @rawr already pointed out). Furthermore, you must start the roxygen code with a title, which is simply the first line of the roxygen section. – Stibu Feb 27 '16 at 16:38
  • sorry @Stibu I tried changing the first part to `summary <- function(object, ...){ UseMethod("summary") }` But I got the following warning, `* checking S3 generic/method consistency ... WARNING summary: function(object, ...) summary.diversityoccupancy: function(x, ...)` Which I didn't have. Sorry to bother you, but I just didn't get it. Could you show me and example of how to change it? – Derek Corcoran Feb 29 '16 at 12:34
  • sorry @rawr I tried changing the first part to `summary <- function(object, ...){ UseMethod("summary") }` But I got the following warning, `* checking S3 generic/method consistency ... WARNING summary: function(object, ...) summary.diversityoccupancy: function(x, ...)` Which I didn't have. Sorry to bother you, but I just didn't get it. Could you show me and example of how to change it? – Derek Corcoran Feb 29 '16 at 12:34
  • 1
    you've sort of taken both suggestions and jumbled them together. get rid of the `summary <- function` completely and use `summary.diversityoccupancy <- function(object, ...)` and change your documentation to `object` instead of `x` like [here](https://github.com/ropensci/spocc/blob/074083f5c5965051410828399ae17352a163b3df/R/methods.r#L101:L104) – rawr Feb 29 '16 at 15:15
  • @rawr I feel really stupid, but I tried what you had in your code and got more warnings, is there any chance we can keep discussing this in any other way? can I send you an E-mail? my mail is derek.corcoran.barrios@gmail.com – Derek Corcoran Feb 29 '16 at 20:43

0 Answers0