[R-pkg-devel] Note: no function found corresponding to methods exports for show

Mikael Jagan j@g@nmn2 @end|ng |rom gm@||@com
Mon Oct 9 15:05:41 CEST 2023



On 2023-10-08 5:43 pm, Mikael Jagan wrote:
>> Hi,
>>
>> I recently submitted my first R package to CRAN, and I encountered a NOTE
>> during the checking process. The NOTE looks like this:
>>
>> =============================================================
>> Flavor: r-devel-linux-x86_64-debian-gcc, r-devel-windows-x86_64
>> Check: whether the namespace can be loaded with stated dependencies,
>> Result: NOTE
>>     Warning: no function found corresponding to methods exports from 'hmsr'
>> for: 'show'
>>
>>     A namespace must be able to be loaded with just the base namespace
>>     loaded: otherwise if the namespace gets loaded by a saved object, the
>>     session will be unable to start.
>>
>>     Probably some imports need to be declared in the NAMESPACE file.
> 
> Sounds like your NAMESPACE is missing importFrom(methods, show) ... ?
> I'm not sure why you could not reproduce the problem locally, given that
> check uses _R_CHECK_CODE_USAGE_WITH_ONLY_BASE_ATTACHED_=true by default.

Reading tools:::.check_packages I see that this environment variable is
not relevant to this particular test.  Still, do import generic functions
for which you define methods, from all packages != "base".

Mikael

> But it is hard to say anything without a link to the package sources ...
> 
> Mikael
> 
>> =============================================================
>>
>> I'm seeking help to understand and address this issue. show is defined like
>> this:
>>
>> #' Show method for class "hms".#'#' @param object - hms s4 object#'#'
>> @return It returns the names of the slots and the classes associated
>> with the#' slots in the "hms" class. It prints call details.#'#'
>> @export#'#' @examples
>> #' f <- function(x) x
>> #' result <- hms(fitness = f, lower = -5, upper = 5)
>> #' show(result)
>> setMethod("show", "hms", function(object) {
>>     cat("An object of class \"hms\"\n")
>>     cat("\nCall:\n", deparse(object using call), "\n\n", sep = "")
>>     cat("Available slots:\n")
>>     print(methods::slotNames(object))})
>>
>> And in the NAMESPACE there is a line that looks like this:
>>
>> exportMethods(show)
>>
>> I was investigating if the show is defined correctly and the GA package has
>> a very similar method:
>>
>> setMethod("show", "ga",function(object)
>>    { cat("An object of class \"ga\"\n")
>>      cat("\nCall:\n", deparse(object using call), "\n\n",sep="")
>>      cat("Available slots:\n")
>>      print(slotNames(object))})
>>
>> I could not reproduce this NOTE on my personal machine with Windows.
>> On Mac OS I have never experienced this NOTE.
>>
>>
>> Best regards
>>
>> Wojciech Achtelik




More information about the R-package-devel mailing list