Re: [R-pkg-devel] Conditionally register method with generic in other package

2017-12-06 Thread Duncan Murdoch

On 06/12/2017 8:44 AM, Bill Denney wrote:



On Dec 6, 2017, at 07:45, Joshua Ulrich  wrote:

To avoid excessive dependencies, I would like to only register
foo.bar() if package A is installed at the time package B is
installed.  If package A is installed after package B, then warn the
user when package B is loaded and/or attached, so they can re-install
A and have foo.bar() registered correctly.


One simple solution would be to wrap the instantiation of foo.bar in a require 
test:

if (require(A)) {
   foo.bar <- function(...) {
 print("To be or not to be")
   }
} else {
   message("To use the foo.bar function, please install package A.")
}



It's usually better to use requireNamespace("A") instead of require("A") 
(and the quotes are needed in requireNamespace(), but optional in 
require()). That tries to load the package, but doesn't mess with the 
search list.


But that'll likely cause warnings, unless the same condition is used in 
the NAMESPACE file where there should be an entry


S3method(foo, bar)

The thing is, I'm not sure if

if (requireNamespace("A"))
  S3method(foo, bar)

is legal in a NAMESPACE file.

Duncan Murdoch

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Conditionally register method with generic in other package

2017-12-06 Thread Bill Denney

> On Dec 6, 2017, at 07:45, Joshua Ulrich  wrote:
> 
> To avoid excessive dependencies, I would like to only register
> foo.bar() if package A is installed at the time package B is
> installed.  If package A is installed after package B, then warn the
> user when package B is loaded and/or attached, so they can re-install
> A and have foo.bar() registered correctly.

One simple solution would be to wrap the instantiation of foo.bar in a require 
test:

if (require(A)) {
  foo.bar <- function(...) {
print("To be or not to be")
  }
} else {
  message("To use the foo.bar function, please install package A.")
}

Thanks,

Bill
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error in re-building vignettes (SOLVED)

2017-12-06 Thread Göran Broström

Hi again,

today I INSTALLED R-devel (2017-12-05 r73849) and updated all packages

> update.packages(checkBuilt = TRUE)

and rebuilt eha_2.5.1 and now all checks passed! Maybe the update of 
packages was necessary.


On its way to CRAN now.

Göran

On 2017-12-05 21:51, Göran Broström wrote:

Hi,

I am checking my eha package with R-3.4.3:

goran@M6800:~/R$ R CMD check --as-cran eha_2.5.1.tar.gz

which results in

* DONE

Status: OK

Fine, but with R-devel (2017-12-04 r73829)

goran@M6800:~/R$ ~/src/R-devel/bin/R CMD check --as-cran eha_2.5.1.tar.gz

.

* checking re-building of vignette outputs ... WARNING
Error in re-building vignettes:
   ...

  *** caught segfault ***
address 0x1, cause 'memory not mapped'

Traceback:
  1: .Call(C_stri_locate_all_regex, str, pattern, omit_no_match, 
opts_regex)
  2: stri_locate_all_regex(string, pattern, omit_no_match = TRUE, 
opts_regex = opts)

  3: stringr::str_locate_all(input, inline.code)
  4: parse_inline(g, patterns)
  5: FUN(X[[i]], ...)
  6: lapply(groups, function(g) {    block = grepl(chunk.begin, g[1]) if 
(!set.preamble && !parent_mode()) {    return(if (block) "" else 
g)    }    if (block) {    n = length(g)    if (n >= 2 && 
grepl(chunk.end, g[n])) g = g[-n]    g = strip_block(g, 
patterns$chunk.code)    params.src = if (group_pattern(chunk.begin)) 
{    stringr::str_trim(gsub(chunk.begin, "\\1", g[1]))    } 
   else ""    parse_block(g[-1], g[1], params.src)    }    else 
parse_inline(g, patterns)})

  7: split_file(lines = text)
  8: process_file(text, output)
  9: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet, 
    encoding = encoding)
10: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = 
globalenv())

11: vweave_rmarkdown(...)
12: engine$weave(file, quiet = quiet, encoding = enc)
13: doTryCatch(return(expr), name, parentenv, handler)
14: tryCatchOne(expr, names, parentenv, handlers[[1L]])
15: tryCatchList(expr, classes, parentenv, handlers)
16: tryCatch({    engine$weave(file, quiet = quiet, encoding = enc) 
setwd(startdir)    find_vignette_product(name, by = "weave", engine = 
engine)}, error = function(e) {    stop(gettextf("processing vignette 
'%s' failed with diagnostics:\n%s", file, conditionMessage(e)), 
domain = NA, call. = FALSE)})

17: buildVignettes(dir = "/home/goran/R/eha.Rcheck/vign_test/eha")
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)

* checking PDF version of manual ... OK
* DONE

Status: 1 WARNING, 2 NOTEs

So, can I send this version of eha to CRAN?

Göran Broström

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel