The error messages indicate that there's an issue with the overloaded operator '[]' being ambiguous when used with NumericVector types in the fitch64.cpp file within the phangorn package. This is likely because the emcc compiler (Emscripten) used for compiling to WebAssembly is more strict or behaves differently than traditional C++ compilers regarding operator overloading and ambiguity resolution.
The error stems from the fact that the [] operator is overloaded in the Rcpp::NumericVector class, and the compiler cannot decide which version of the operator to use when given a long index type. Specifically, the error points out that the compiler is confused between using NumericVector's operator[] and the built-in array operator[].
To address this issue, explicit type conversion to the appropriate index type expected by the NumericVector class might help. R_xlen_t is the index type used by Rcpp for indexing, which is compatible with the indexing of Rcpp vectors. Modifying the code to explicitly cast the index to R_xlen_t could resolve the ambiguity.
However, as you cannot directly modify the source code of the phangorn package without forking or creating a pull request to the original repository, one solution could be to locally modify a copy of phangorn, apply the necessary changes, and then attempt to recompile. This approach requires a good understanding of both C++ and R package development.
For a more general solution that doesn't involve modifying the package's source code, you might consider reporting this issue to the package maintainers. They might be able to provide a fix or update that ensures compatibility with WebAssembly compilation.
As a temporary workaround, if your project allows, you could try using alternative methods or packages that offer similar functionalities as phangorn but don't encounter the same compilation issues with WebAssembly.
Also from what i can see this package has the following dependencies:
Rcpp 1.0.12 [dl] {Supports webR / wasm}
ape 5.7-1 [dl] {Supports webR / wasm}
digest 0.6.34 [dl] {Supports webR / wasm}
fastmatch 1.1-4 [dl] {Supports webR / wasm}
igraph 2.0.2 [dl] {Supports webR / wasm}
quadprog 1.5-8 [dl] {Supports webR / wasm}
So its a pity for this package to not support webR / wasm
Hey, Would it be possible that this packages gets complied to emscripten to be able to be used with webR.
UPDATE when i try to compile it i get the following error:
ChatGPT explanation:
Also from what i can see this package has the following dependencies:
So its a pity for this package to not support webR / wasm