[R-pkg-devel] Extending proj with proj.line3d methods and overloading the methods

Leo Mada |eo@m@d@ @end|ng |rom @yon|c@eu
Fri Apr 26 23:49:47 CEST 2024


Dear List-Members,

I try to implement a proj.line3d method and to overload this method as follows:

proj.line3d <- function(p, x, y, z, ...)
  UseMethod("proj.line3d")

proj.line3d.numeric = function(p, x, y, z, ...) {
  # ...
}

proj.line3d.matrix = function(p, x, y, z, ...) {
  # ...
}

The code is available on GitHub, specifically in:
https://github.com/discoleo/Rpdb/blob/main/R/proj.R


However, I encountered various issues both with running proj.line3d and with documenting the functions in order to pass the CRAN-checks.

# ERROR: Executing function

p = c(1,2,3)
line = matrix(c(0,5,2,3,1,4), 2)
proj.line3d(p, line)
#  Error in UseMethod("proj.line3d") :
#   no applicable method for 'proj.line3d' applied to an object of class "c('double', 'numeric')"

I do prefer to have the methods named as "proj._name_" so that they are easily searchable using methods(proj). It's possible to project a point on a line, or a point on a plane, or other more complex projections. Therefore, more methods are possible in the future.

methods(proj)
# [1] proj.aov*           proj.aovlist*       proj.default*       proj.line3d
# [5] proj.line3d.matrix  proj.line3d.numeric proj.lm

I think it is wise to solve first this issue before solving the documentation issues.

Many thnaks,

Leonard



	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list