Tmap: knit_print tmap

Created on 8 Dec 2018  路  10Comments  路  Source: mtennekes/tmap

Got this mail from Kurt:

Dear maintainer,

Apparently your package has S3 methods it does not register via
NAMESPACE and instead exports, so that these methods can only be found
on the search path.  The CRAN run time tests find at least

  S3 method lookup found 'knit_print.tmap' on search path 
  S3 method lookup found 'knit_print.tmap_arrange' on search path 

there may be more.

Presumably, you did not register the methods as this requires the
generic to be imported, and hence the namespace of the generic and all
its dependencies to be loaded, which maintainers often prefer to avoid
for S3 methods which are really only needed when the namespace of their
generic is loaded.

For the current development version of R, we have recently added a
simple mechanism for delayed S3 registration: using 

   if(getRversion() >= "3.6.0") {
       S3method(pkg::gen, cls)
   }

will register 'gen.cls' as S3 method for class 'cls' and generic 'gen'
from package 'pkg' only when the namespace of 'pkg' is loaded.
(Similarly, one can use

   if(getRversion() >= "3.6.0") {
       S3method(pkg::gen, cls, fun)
   }

in case the method is named 'fun' and not 'gen.cls'.)

Can you please add the necessary delayed S3 method registrations to your
NAMESPACE, and submit a new version of your package as quickly as 
possible?

Best
-k

Anyone knows how to solve this? The problem is that knitr is not imported by tmap. See https://cran.r-project.org/web/packages/knitr/vignettes/knit_print.html (bottom).

I tried to do #' @method knit_print tmap, but then it can't find knit_print since it is not imported.

@tim-salabim: did you also got this email?

question

Most helpful comment

All 10 comments

If I understand the above email correctly, you probably should add something like this:

   if(getRversion() >= "3.6.0") {
       S3method(knitr::knit_print, tmap)
   }

I am unsure where it exactly should be added though...

It should be added in the NAMESPACE which is generated automatically via roxygen2. How can we do this using roxygen2?

I did receive the same message form Kurt Hornik and have exactly the same issue regarding knit_print not being imported... The only way I could get around it on win-builder with r-devel is to import knitr which seems quite drastic...

So, keeping everything as is and adding

 if(getRversion() >= "3.6.0") {
       S3method(knitr::knit_print,mapview)
   }

manually to the NAMESPACE (after the package has been documented using roxygen) and then building the package from the command line with R CMD build rather than using devtools seems to not trigger any ERRORs on win-builder.

I have written an email to CRAN maintainers asking if we should simply add the entry or also delete the export(knit_print.mapview) entry from the NAMESPACE. Will report back when I hear from them.

And here's the reply from Kurt Hornik:

In principle, it would be best to stop exporting methods when no longer
necessary. I.e., something like

if(getRversion() >= "3.6.0") {
S3method(pkg::gen, cls)
} else {
export(gen.cls)
}

Best
-k

I also just found this which seems useful

I think this commit solves the issue. This is what @talgalili did in dendextend.

mapview now checks fine on win-builder with R-devel. I will report back as soon as I've submitted to CRAN (ant it hopefully gets accepted).

mapview just hit CRAN, so this solutions seems to work!

Brilliant! Many thanks!

tmap 2.2 also made it to CRAN!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Si-Chong picture Si-Chong  路  4Comments

mtennekes picture mtennekes  路  8Comments

MatthieuStigler picture MatthieuStigler  路  3Comments

jarsc568 picture jarsc568  路  8Comments

hbermeo picture hbermeo  路  8Comments