[R] S4 method selection based on second argument

Paul Roebuck roebuck at odin.mdacc.tmc.edu
Tue Sep 28 22:24:45 CEST 2004


I'm translating some Matlab code and need some help figuring
out how to change this call into an S4 generic method.

In matlab, there's a function called 'repmat' with three
calling sequences (all I have to deal with anyway):
    1) B = repmat(A, m, n)
    2) B = repmat(A, [m n])
    3) B = repmat(A, n)
In all cases, A is the fill value, m is number of rows,
and n is number of columns.

As separate functions, the translations would roughly be:

repmat1 <- function(A, m, n) {
    kronecker(matrix(1, n, m), A)
}

repmat2 <- function(A, rc) {
    repmat1(A, rc[1], rc[2])
}

repmat3 <- function(A, n) {
    repmat1(A, n, n)
}

Suggestions?


----------------------------------------------------------
SIGSIG -- signature too long (core dumped)




More information about the R-help mailing list