[R-pkg-devel] A simple question regarding examples

Hanyu Song h@nyu@@ong @end|ng |rom duke@edu
Fri Sep 22 00:11:37 CEST 2023


Hello Duncan and Ivan,

Thank you for your prompt response! Perhaps I should add that:

I don't think the Python module "ctef" exists on CRAN. Therefore, I am very surprised that the example below runs overtime, since all it has to do is to run reticulate::py_module_available('ctef'). If even this part is running overtime, I am not quite sure how to deal with it.

#' if (reticulate::py_module_available('ctef')) {
#' res <- my_func(input1, input2)
#' }

Looking forward to your reply.

Best,
Hanyu
________________________________
From: Duncan Murdoch <murdoch.duncan using gmail.com>
Sent: Thursday, September 21, 2023 6:44 AM
To: Hanyu Song <hanyu.song using duke.edu>; r-package-devel using r-project.org <r-package-devel using r-project.org>
Subject: Re: [R-pkg-devel] A simple question regarding examples

On 20/09/2023 8:03 p.m., Hanyu Song wrote:
> Hello,
>
> I have a simple question about including examples. My code depends on a rarely used Python module, so I am using the @examplesIf tag per Hadley Wickham's advice as follows:
>
> #' @examplesIf reticulate::py_module_available('ctef')
> #'  res <- my_func(input1, input2)
>
> Unfortunately, my_func runs overtime during the CRAN check. To resolve this, do I simply use the less elegant approach as follows?
>
> #' \dontrun{
> #' if (reticulate::py_module_available('ctef')) {
> #' res <- my_func(input1, input2)
> #' }
>

The @examplesIf comments are directed at Roxygen; R checks will never
look at them.  R will run tests based on what is in the my_func.Rd
examples section.  I'd guess that's pretty similar to your second
version (except for the \dontrun part, which you shouldn't use, as Ivan
said).

Duncan Murdoch

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list