[R-pkg-devel] r-patched error

Duncan Murdoch murdoch@dunc@n @ending from gm@il@com
Mon Jun 4 14:26:09 CEST 2018


On 04/06/2018 7:34 AM, David Hugh-Jones wrote:
> Hi all,
> 
> Latest release of my package has an error when checked on r-patched-linux
> and r-devel-linux. Relevant output is shown below (from
> https://cran.r-project.org/web/checks/check_results_huxtable.html). It
> suggests that there's no method for `align<-` and `bold` for huxtable
> objects. In fact the package defines and exports such methods. Selected
> lines from the NAMESPACE file:
> 
> S3method("align<-",huxtable)
> S3method(bold,huxtable)
> export("align<-")
> export("align<-.huxtable")
> export(bold)
> export(bold.huxtable)
> 

I'd worry a little bit about your "make_getter_setters" function:  it 
saves the result using

   lapply(names(funs), function (x) {
     assign(x, funs[[x]], envir = parent.frame(3)) # 3: 1 for 
function(x), 2 for lapply, 3 for the caller!
   })

That count of 3 looks like an implementation detail that could 
conceivably vary, for instance if the compiler decided to optimize out a 
call or two, or lapply's implementation changed.  (I suspect this isn't 
the cause of the error you saw, or you would have seen it a lot more: 
but I'd still fix it.)

I think a safer way to find the huxtable namespace is something like

huxtableNamespace <- .getNamespace("huxtable")

though this is advised against; a documented but less obvious way to do 
it would be

huxtableNamespace <- environment(huxtable)

The "huxtable" on the right is the function; most other functions in 
your package would also be fine, as long as you haven't done anything 
tricky to change their environments.

With one of those definitions, you could change your lapply() to

   lapply(names(funs), function (x) {
     assign(x, funs[[x]], envir = huxtableNamespace)
   })

 > Checks are passing fine on other platforms. Is this just a weirdness 
to do
 > with the changes in R 3.5.0 on Linux? Or does it indicate a real problem?

A possibility is memory corruption at the C level.  Since you don't have 
any C code in huxtable that couldn't be caused by what you did, but you 
might still be a victim of it.

Duncan Murdoch


> 
> Cheers,
> David
> 
>      > ### ** Examples
>      >
>      >
>      > ht <- huxtable(a = 1:3, b = 1:3)
>      > align(ht) <- 'right'
>      Error in UseMethod("align<-") :
>       no applicable method for 'align<-' applied to an object of class
> "c('huxtable', 'data.frame')"
>      Calls: align<-
>      Execution halted
> Flavor: r-patched-linux-x86_64
> <https://www.r-project.org/nosvn/R.check/r-patched-linux-x86_64/huxtable-00check.html>
> 
> Version: 4.0.0
> Check: re-building of vignette outputs
> Result: WARN
>      Error in re-building vignettes:
>       ...
>      Quitting from lines 52-104 (design-principles.Rmd)
>      Error: processing vignette ‘design-principles.Rmd’ failed with
> diagnostics:
>      no applicable method for ‘bold’ applied to an object of class
> "c('huxtable', 'data.frame')"
>      Execution halted
> Flavor: r-patched-linux-x86_64
> <https://www.r-project.org/nosvn/R.check/r-patched-linux-x86_64/huxtable-00check.html>
> David
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>



More information about the R-package-devel mailing list