[R-pkg-devel] Two errors

Sharon Bewick @bew|ck @end|ng |rom c|em@on@edu
Sat Jul 5 01:03:51 CEST 2025


So I think the only solution that CRAN will accept is linking against headers. I can download an ape.h header file, but for the life of me, I’m having trouble figuring out how to link it in my R package. I’ve read what I can find online, but haven’t been successful. Right now, I have the ape.h file in an src folder. I also have
LinkingTo: Rcpp, ape
In my DESCRIPTION file

But I’m getting all sorts of errors. Does anyone have an example of how I can do this that I might be able to work from?

Thanks in advance!!!!
Sharon


From: Iris Simmons <ikwsimmo using gmail.com>
Date: Thursday, July 3, 2025 at 5:11 PM
To: Sharon Bewick <sbewick using clemson.edu>
Cc: Michael Chirico <michaelchirico4 using gmail.com>, R Package Development <r-package-devel using r-project.org>
Subject: Re: [R-pkg-devel] Two errors
This Message Is From An External Sender: Use caution when opening links or attachments if you do not recognize the sender.

I believe the suggestion was that you should alternatively write:

.Call("seq_root2tip", nt$edge, length(nt$tip.label), nt$Nnode, PACKAGE = "ape")

however, that generates the following note that CRAN is very unlikely to accept:

* checking foreign function calls ... NOTE
Foreign function call to a different package:
  .Call("seq_root2tip", ..., PACKAGE = "ape")
See chapter 'System and foreign language interfaces' in the 'Writing R
Extensions' manual.

The other possibility is adding:

importFrom(ape, seq_root2tip)

to your NAMESPACE and not modifying your code, but that generates a
different note:

* checking foreign function calls ... NOTE
Registration problem:
  symbol 'seq_root2tip' not in namespace:
   .Call(seq_root2tip, ...)
See chapter 'System and foreign language interfaces' in the 'Writing R
Extensions' manual.

Your best bet is to ask the maintainers of package:ape to add and
export an R function like this:

idk <- function (...)
.Call(seq_root2tip, ...)

There are also ways to do it in C using R_RegisterCCallable and
R_GetCCallable but that might be too complicated for something like
this.

On Thu, Jul 3, 2025 at 6:33 PM Sharon Bewick <sbewick using clemson.edu> wrote:
>
> Thanks so much for the tips!
>
> I think I’ve fixed #2. But I’m not sure what you mean by #1. Where should the "seq_root2tip" with PACKAGE="ape" go? In the NAMESPACE file? In the Description file? Somewhere in the code?
>
> So sorry for not understanding!
>
> Thanks!
> Sharon
>
> From: Michael Chirico <michaelchirico4 using gmail.com>
> Date: Thursday, July 3, 2025 at 4:13 PM
> To: Sharon Bewick <sbewick using clemson.edu>
> Cc: R Package Development <r-package-devel using r-project.org>
> Subject: Re: [R-pkg-devel] Two errors
>
> This Message Is From An External Sender: Use caution when opening links or attachments if you do not recognize the sender.
> 1. all functions in R are variables. You can "trick" code tools by writing seq_root2tip=NULL in the same scope but consider (a) C routines are typically part of a package's private interface (b) it might be preferable to use the string "seq_root2tip" with PACKAGE="ape"
>
> 2. phytree is not the same as phytree<- : importFrom(phyloseq, "phytree<-") is what you want assuming it's exported)
>
> (c.f. `x = phyteee(...)` vs. `phytree(x) <- ...`)
>
> Mike C
> On Thu, Jul 3, 2025, 2:57 PM Sharon Bewick <sbewick using clemson.edu<mailto:sbewick using clemson.edu>> wrote:
> 1. I’m trying to upload my R package. However, I use the ape function seq_root2tip but for the sake of speed am calling it using .Call:
>
> toroot<-.Call(seq_root2tip, nt$edge, length(nt$tip.label), nt$Nnode)
>
> How do I get R to recognize the seq_root2tip function from ape in this C call? It is throwing up a NOTE that is getting my package rejected:
>
> shade_branch: no visible binding for global variable ‘seq_root2tip’
>
> but seq_root2tip is a function, not a global variable.
>
> 2. I’m also getting a NOTE about: no visible global function definition for ‘phy_tree<-’
>
> I have declared phy_tree in the NAMESPACE file: importFrom(phyloseq,phy_tree)
>
> I don’t know what the problem is…
>
> Thanks!
> Sharon
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org<mailto:R-package-devel using r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel<https://stat.ethz.ch/mailman/listinfo/r-package-devel>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel<https://stat.ethz.ch/mailman/listinfo/r-package-devel>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list