[R-pkg-devel] Visible bindings and reference classes

Colin Gillespie csgillespie at gmail.com
Tue Aug 11 15:32:39 CEST 2015


>
>
> To your question:
>
> Reference classes are used in *many* places,  and the use of  ' <<- '
> is really "standard" there.
> e.g., package 'lme4', or 'pcalg' are two packages I'm involved with,
> which use ref.classes and ' <<- '  but are "fine" with that.
>
> So there must be something peculiar in your package leading to
> the  <<-  warnings.
>

After a bit more investigating I've narrowed it down.  The notes can be
generated by having

d1 = setRefClass("d1", fields=list(x = "numeric"))
d1$accessors("x")

**and** having ByteCompile: true. Commenting out the accessors line removes
the visible binding note. The  x=NULL  or globalVariables("x") trick
doesn't work.

A stackoverflow answer suggests that I need to add

assign(variable,NULL, envir = .GlobalEnv)

but this generates a new NOTE under R CMD check

I've not been able to find another package that uses accessors and
ByteCompile

Thanks

Colin










>
> Maybe you should look into the source code of such other CRAN
> packages to see how "they" do it differently than you.
>
> Best regards,
> Martin
>
> Martin Maechler, ETH Zurich
>
>
> > After some googling, I came across the page
> > http://stackoverflow.com/q/23475309/203420 which suggests
> >
> > suppressBindingNotes <- function(variablesMentionedInNotes) {
> >   for(variable in variablesMentionedInNotes) {
> >     assign(variable,NULL, envir = .GlobalEnv)
> >   }
> > }
> > suppressBindingNotes(c("dat", "internal", "xmin", "pars", "no_pars"))
> >
> > But checking the package with --as-cran raises the note
> >
> > * checking R code for possible problems ... NOTE
> > Found the following assignments to the global environment:
> >   File ‘poweRlaw/R/aaa_all_classes.R’:
> >   assign(variable, NULL, envir = .GlobalEnv)
> >
> > What is the correct way of removing the "visible bindings" notes?
> >
> > Thanks
> >
> > Colin
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-package-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list